Skip to content

[Assetic] complete XML configuration examples #6015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cookbook/assetic/apply_to_option.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ An example configuration might look like this:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="coffee"
Expand All @@ -35,6 +43,7 @@ An example configuration might look like this:
<assetic:node-path>/usr/lib/node_modules/</assetic:node-path>
</assetic:filter>
</assetic:config>
</container>

.. code-block:: php

Expand Down Expand Up @@ -137,6 +146,14 @@ In this case you can specify that the ``coffee`` filter is applied to all
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="coffee"
Expand All @@ -145,6 +162,7 @@ In this case you can specify that the ``coffee`` filter is applied to all
apply_to="\.coffee$" />
<assetic:node-paths>/usr/lib/node_modules/</assetic:node-path>
</assetic:config>
</container>

.. code-block:: php

Expand Down
24 changes: 23 additions & 1 deletion cookbook/assetic/asset_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ configuration under the ``assetic`` section. Read more in the
<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic">
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:asset name="jquery_and_ui">
Expand Down Expand Up @@ -388,11 +392,20 @@ should be defined:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="uglifyjs2"
bin="/usr/local/bin/uglifyjs" />
</assetic:config>
</container>

.. code-block:: php

Expand Down Expand Up @@ -528,7 +541,16 @@ the following change in your ``config_dev.yml`` file:
.. code-block:: xml

<!-- app/config/config_dev.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config use-controller="false" />
</container>

.. code-block:: php

Expand Down
45 changes: 45 additions & 0 deletions cookbook/assetic/jpeg_optimize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ using the ``bin`` option of the ``jpegoptim`` filter:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="jpegoptim"
bin="path/to/jpegoptim" />
</assetic:config>
</container>

.. code-block:: php

Expand Down Expand Up @@ -88,12 +97,21 @@ to ``true``:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="jpegoptim"
bin="path/to/jpegoptim"
strip_all="true" />
</assetic:config>
</container>

.. code-block:: php

Expand Down Expand Up @@ -129,12 +147,21 @@ be at the expense of its quality:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="jpegoptim"
bin="path/to/jpegoptim"
max="70" />
</assetic:config>
</container>

.. code-block:: php

Expand Down Expand Up @@ -171,6 +198,14 @@ following configuration:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="jpegoptim"
Expand All @@ -180,6 +215,7 @@ following configuration:
name="jpegoptim" />
</assetic:twig>
</assetic:config>
</container>

.. code-block:: php

Expand Down Expand Up @@ -221,6 +257,14 @@ file:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="jpegoptim"
Expand All @@ -231,6 +275,7 @@ file:
output="images/*.jpg" />
</assetic:twig>
</assetic:config>
</container>

.. code-block:: php

Expand Down
12 changes: 10 additions & 2 deletions cookbook/assetic/php.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ First, configure a new ``scssphp`` Assetic filter:
<!-- app/config/config.xml -->
<?xml version="1.0" charset="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic">
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<filter name="scssphp" formatter="Leafo\ScssPhp\Formatter\Compressed" />
Expand Down Expand Up @@ -159,7 +163,11 @@ First, configure a new ``jsqueeze`` Assetic filter as follows:
<!-- app/config/config.xml -->
<?xml version="1.0" charset="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic">
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<filter name="jsqueeze" />
Expand Down
27 changes: 27 additions & 0 deletions cookbook/assetic/uglifyjs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,21 @@ your JavaScripts:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<!-- bin: the path to the uglifyjs executable -->
<assetic:filter
name="uglifyjs2"
bin="/usr/local/bin/uglifyjs" />
</assetic:config>
</container>

.. code-block:: php

Expand Down Expand Up @@ -137,12 +146,21 @@ can configure its location using the ``node`` key:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config
node="/usr/bin/nodejs" >
<assetic:filter
name="uglifyjs2"
bin="/usr/local/bin/uglifyjs" />
</assetic:config>
</container>

.. code-block:: php

Expand Down Expand Up @@ -253,11 +271,20 @@ Next, add the configuration for this filter:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="uglifycss"
bin="/usr/local/bin/uglifycss" />
</assetic:config>
</container>

.. code-block:: php

Expand Down
9 changes: 9 additions & 0 deletions cookbook/assetic/yuicompressor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ stylesheets:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config>
<assetic:filter
name="yui_css"
Expand All @@ -51,6 +59,7 @@ stylesheets:
name="yui_js"
jar="%kernel.root_dir%/Resources/java/yuicompressor.jar" />
</assetic:config>
</container>

.. code-block:: php

Expand Down
8 changes: 8 additions & 0 deletions cookbook/configuration/override_dir_structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,17 @@ the ``extra.symfony-web-dir`` option in the ``composer.json`` file:
.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<!-- ... -->
<assetic:config read-from="%kernel.root_dir%/../../public_html" />
</container>

.. code-block:: php

Expand Down
14 changes: 11 additions & 3 deletions reference/configuration/assetic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,23 @@ Full Default Configuration

.. code-block:: xml

<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config
debug="%kernel.debug%"
use-controller="%kernel.debug%"
read-from="%assetic.read_from%"
write-to="%kernel.root_dir%/../web"
java="/usr/bin/java"
node="/usr/bin/node"
sass="/usr/bin/sass"
>
sass="/usr/bin/sass">

<!-- Defaults (all currently registered bundles) -->
<assetic:bundle>FrameworkBundle</assetic:bundle>
<assetic:bundle>SecurityBundle</assetic:bundle>
Expand Down Expand Up @@ -99,5 +107,5 @@ Full Default Configuration
<assetic:name />
</assetic:functions>
</assetic:twig>

</assetic:config>
</container>