|  | 
| 4 | 4 | How to Use Assetic for Asset Management | 
| 5 | 5 | ======================================= | 
| 6 | 6 | 
 | 
|  | 7 | +Installing and Enabling Assetic | 
|  | 8 | +------------------------------- | 
|  | 9 | + | 
|  | 10 | +Starting from Symfony 2.8, Assetic is no longer included by default in the | 
|  | 11 | +Symfony Standard Edition. Before using any of its features, install the | 
|  | 12 | +AsseticBundle executing this console command in your project: | 
|  | 13 | + | 
|  | 14 | +    .. code-block:: bash | 
|  | 15 | +
 | 
|  | 16 | +        $ composer require symfony/assetic-bundle | 
|  | 17 | +
 | 
|  | 18 | +Then, enable the bundle in the ``AppKernel`` file of your Symfony application:: | 
|  | 19 | + | 
|  | 20 | +    // app/AppKernel.php | 
|  | 21 | + | 
|  | 22 | +    // ... | 
|  | 23 | +    class AppKernel extends Kernel | 
|  | 24 | +    { | 
|  | 25 | +        // ... | 
|  | 26 | + | 
|  | 27 | +        public function registerBundles() | 
|  | 28 | +        { | 
|  | 29 | +            $bundles = array( | 
|  | 30 | +                // ... | 
|  | 31 | +                new Symfony\Bundle\AsseticBundle\AsseticBundle(), | 
|  | 32 | +            ); | 
|  | 33 | + | 
|  | 34 | +            // ... | 
|  | 35 | +        } | 
|  | 36 | +    } | 
|  | 37 | + | 
|  | 38 | +Finally, add the following minimal configuration to enable Assetic support in | 
|  | 39 | +your application: | 
|  | 40 | + | 
|  | 41 | +.. configuration-block:: | 
|  | 42 | + | 
|  | 43 | +    .. code-block:: yaml | 
|  | 44 | +
 | 
|  | 45 | +        # app/config/config.yml | 
|  | 46 | +        assetic: | 
|  | 47 | +            debug:          "%kernel.debug%" | 
|  | 48 | +            use_controller: false | 
|  | 49 | +            filters: | 
|  | 50 | +                cssrewrite: ~ | 
|  | 51 | +
 | 
|  | 52 | +        # ... | 
|  | 53 | +
 | 
|  | 54 | +    .. code-block:: xml | 
|  | 55 | +
 | 
|  | 56 | +        <!-- app/config/config.xml --> | 
|  | 57 | +        <?xml version="1.0" encoding="UTF-8" ?> | 
|  | 58 | +        <container xmlns="http://symfony.com/schema/dic/services" | 
|  | 59 | +            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 
|  | 60 | +            xmlns:framework="http://symfony.com/schema/dic/symfony" | 
|  | 61 | +            xmlns:twig="http://symfony.com/schema/dic/twig" | 
|  | 62 | +            xsi:schemaLocation="http://symfony.com/schema/dic/services | 
|  | 63 | +                http://symfony.com/schema/dic/services/services-1.0.xsd | 
|  | 64 | +                http://symfony.com/schema/dic/symfony | 
|  | 65 | +                http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | 
|  | 66 | +
 | 
|  | 67 | +            <assetic:config debug="%kernel.debug%" use-controller="%kernel.debug%"> | 
|  | 68 | +                <assetic:filters cssrewrite="null" /> | 
|  | 69 | +            </assetic:config> | 
|  | 70 | +
 | 
|  | 71 | +            <!-- ... --> | 
|  | 72 | +        </container> | 
|  | 73 | +
 | 
|  | 74 | +    .. code-block:: php | 
|  | 75 | +
 | 
|  | 76 | +        // app/config/config.php | 
|  | 77 | +
 | 
|  | 78 | +        $container->loadFromExtension('assetic', array( | 
|  | 79 | +            'debug' => '%kernel.debug%', | 
|  | 80 | +            'use_controller' => '%kernel.debug%', | 
|  | 81 | +            'filters' => array( | 
|  | 82 | +                'cssrewrite' => null, | 
|  | 83 | +            ), | 
|  | 84 | +            // ... | 
|  | 85 | +        )); | 
|  | 86 | +
 | 
|  | 87 | +        // ... | 
|  | 88 | +
 | 
|  | 89 | +Introducing Assetic | 
|  | 90 | +------------------- | 
|  | 91 | + | 
| 7 | 92 | Assetic combines two major ideas: :ref:`assets <cookbook-assetic-assets>` and | 
| 8 | 93 | :ref:`filters <cookbook-assetic-filters>`. The assets are files such as CSS, | 
| 9 | 94 | JavaScript and image files. The filters are things that can be applied to | 
|  | 
0 commit comments