1

When I add such lines in my layout.html.php:

<?php foreach ($view['assetic']->stylesheets(
    array('@AnglerBackendBundle/Resources/public/css/*')
    ) as $url
    ): ?>
    <link rel="stylesheet" href="<?= $view->escape($url) ?>" />
<?php endforeach ?>

Config:

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    # java: /usr/bin/java
    filters:
        cssrewrite: ~
        # closure:
        #     jar: %kernel.root_dir%/java/compiler.jar
        yui_css:
             jar: %kernel.root_dir%/java/yuicompressor.jar
        yui_js:
             jar: %kernel.root_dir%/java/yuicompressor.jar

I see 5 tags link with 5 resourses but according to Symfony 2 docs I should see only one file. What I did wrong

4
  • 1
    Are you testing it in the development environment? If so, this is normal behaviour. symfony.com/doc/current/cookbook/assetic/asset_management.html : "In the dev environment, each file is still served individually, so that you can debug problems more easily. However, in the prod environment, this will be rendered as a single script tag." Commented Apr 28, 2012 at 21:50
  • It is so in both of environments. Commented Apr 29, 2012 at 9:29
  • Moreover I can see single file in css folder but still can't understand why it isn't used Commented Apr 29, 2012 at 9:30
  • 1
    Guys all is correct. Previously I set debug parameter of AppKernel as true in app.php. Now it works Commented Apr 30, 2012 at 8:03

1 Answer 1

4

Just to put the answer in an actual answer:

You need to change this: $kernel = new AppKernel('prod', true);

To this: $kernel = new AppKernel('prod', false);

The second parameter is the debug parameter. Assetic will only write one file if debugging is off.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.