2017 © Pedro Peláez
 

symfony-bundle cssurlrewrite-bundle

A small assetic filter for symfony to fix all url paths at css documents to correct urls

image

fkr/cssurlrewrite-bundle

A small assetic filter for symfony to fix all url paths at css documents to correct urls

  • Sunday, August 21, 2016
  • by fkrauthan
  • Repository
  • 2 Watchers
  • 33 Stars
  • 122,831 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 13 Forks
  • 0 Open issues
  • 7 Versions
  • 5 % Grown

The README.md

FkrCssURLRewriteBundle

A small assetic filter for Symfony2 to fix all url paths in css documents to correct urls. It also provides easy resource linking across platforms., (*1)

Installation

Bring in the vendor libraries

This can be done in three different ways:, (*2)

Method #1) Use composer, (*3)

~~~~~ json "require": { "fkr/cssurlrewrite-bundle": "*" }, (*4)


**Method #2**) Use git submodules git submodule add git://github.com/fkrauthan/FkrCssURLRewriteBundle.git vendor/bundles/Fkr/CssURLRewriteBundle **Method #3**) Use deps file [FkrCssURLRewriteBundle] git=git://github.com/fkrauthan/FkrCssURLRewriteBundle.git target=bundles/Fkr/CssURLRewriteBundle Register the Fkr namespaces ----------------------------------------- If not using composer, register the `Fkr` namespace with Symfony's autoloader: ~~~~~ php // app/autoload.php $loader->registerNamespaces(array( 'Fkr' => __DIR__.'/../vendor/bundles', // your other namespaces ));

Add CssURLRewriteBundle to your application kernel

~~~~~ php // app/AppKernel.php public function registerBundles() { return array( // ... new Fkr\CssURLRewriteBundle\FkrCssURLRewriteBundle(), // ... ); }, (*5)


Configuration ============= ~~~~~ yml # app/config.yml fkr_css_url_rewrite: rewrite_only_if_file_exists: true clear_urls: true
  • rewrite_only_if_file_exists: If true (default) only rewrites url if the resource exists in the .../BundleFolder/Resources/public/ folder.
  • clear_urls: If true (default) the generated url gets normalized. For example if the url normaly is .../less/../img this option makes .../img.

Usage

Standard usage, (*6)

If you place your css file for example in, (*7)

.../BundleFolder/Resources/public/css 

and you have your images in, (*8)

../BundleFolder/Resources/public/img

then you have in yours css file somthing like this, (*9)

~~~~~ css background-image: url(../img/MyImageName.png) ~~~~~, (*10)

Now you have to call, (*11)

app/console assets:install

Now if you have somthing like this in your template, (*12)

{% stylesheets filter='css_url_rewrite,?yui_css' 
    '@BundleName/Resources/public/css/mycssfile.css'
%}
    <link rel="stylesheet" href="{{ asset_url }}" type="text/css" />
{% endstylesheets %}

Now the filter rewrites your url in your css file, (*13)

background-image: url(../img/MyImageName.png) => background-image: url(../bundles/bundlename/css/../img/MyImageName.png)

And everything works fine., (*14)

Extended usage, (*15)

You can link images from other bundles by using the @ annotation. For example if you write this in you css file, (*16)

background-image: url(@BundleNameBundle/img/MyImageName.png)

Now the filter rewrite this url in your css file, (*17)

background-image: url(@BundleNameBundle/img/MyImageName.png) => background-image: url(../bundles/bundlename/img/MyImageName.png)

License

Resources/meta/LICENSE, (*18)

The Versions

21/08 2016

dev-master

9999999-dev https://github.com/fkrauthan/FkrCssURLRewriteBundle

A small assetic filter for symfony to fix all url paths at css documents to correct urls

  Sources   Download

MIT

The Requires

 

by Florian Krauthan

css rewrite asset symfony bundle assetic css url cssrewrite

21/08 2016

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/fkrauthan/FkrCssURLRewriteBundle

A small assetic filter for symfony to fix all url paths at css documents to correct urls

  Sources   Download

MIT

The Requires

 

by Florian Krauthan

css rewrite asset symfony bundle assetic css url cssrewrite

21/08 2016

v1.0.4

1.0.4.0 https://github.com/fkrauthan/FkrCssURLRewriteBundle

A small assetic filter for symfony to fix all url paths at css documents to correct urls

  Sources   Download

MIT

The Requires

 

by Florian Krauthan

css rewrite asset symfony bundle assetic css url cssrewrite

25/05 2016

v1.0.3

1.0.3.0 https://github.com/fkrauthan/FkrCssURLRewriteBundle

A small assetic filter for symfony to fix all url paths at css documents to correct urls

  Sources   Download

MIT

The Requires

 

by Florian Krauthan

css rewrite asset symfony bundle assetic css url cssrewrite

24/05 2016

v1.0.2

1.0.2.0 https://github.com/fkrauthan/FkrCssURLRewriteBundle

A small assetic filter for symfony to fix all url paths at css documents to correct urls

  Sources   Download

MIT

The Requires

 

by Florian Krauthan

css rewrite asset symfony bundle assetic css url cssrewrite

23/05 2016

v1.0.1

1.0.1.0 https://github.com/fkrauthan/FkrCssURLRewriteBundle

A small assetic filter for symfony to fix all url paths at css documents to correct urls

  Sources   Download

MIT

The Requires

 

by Florian Krauthan

css rewrite asset symfony bundle assetic css url cssrewrite

04/01 2013

v1.0.0

1.0.0.0 https://github.com/fkrauthan/FkrCssURLRewriteBundle

A small assetic filter for symfony to fix all url paths at css documents to correct urls

  Sources   Download

MIT

The Requires

 

by Florian Krauthan

css rewrite asset symfony bundle assetic css url cssrewrite