Search code examples
phpsymfonyassetic

Where is Symfony and Assetic's CSS path?


{% stylesheets 'bundles/app/css/*' filter='cssrewrite' %}
        <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}

I've tried using Assetic within Symfony 3 to fetch CSS files. However, despite looking in Symfony's documentation, I have no idea where this 'bundles/app/css/*' actually is within Symfony. I've tried putting a css file in /app/css/ but no css files seem to load on load.


Solution

  • bundles/app/css/ is in your web directory.

    The goal of assetic's is that you keep your assetic's files together with all other files in your bundle where they belong to. The problem is that the src/AppBundle directory (there where your bundle content can be found) should not be accessible from the web while assets need to be accessible from the web. For that reason you can store (and edit) your assets in the src/AppBundle/Resources/public directory and when you are done you can copy them to the web directory from the cli with this command:

    php bin/console assets:install

    In the src/AppBundle/Resources/public directory you should create sub-directories like css, js, images and fonts. i.e. src/AppBundle/Resources/public/css