Symfony 2 Assetic css and js 404 within production environment Symfony 2 Assetic css and js 404 within production environment php php

Symfony 2 Assetic css and js 404 within production environment


Hi I think you are having issues because of cssrewrite.

You have two options;

This is an example of the first option

You can specify an output directory for your assets. The example below points to '/web/bundles/yourbundle/css' Do an assets:install --env=prod and assetic:dump --env=prod and I think you are good to go.

{% stylesheets'@admin_css'output='bundles/yourbundle/css/admin_style.css'%}<link href="{{ asset_url }}?{{ AssetVersion }}" rel="stylesheet" type="text/css">{% endstylesheets %}

Also I have to mention that when you define your assets in asset.yml, assetic:dump generates an assets folder in your public assets directory, which you don't need in this case. To get rid of that folder you can use this syntax in twig;

 {% stylesheets'@YourBundle/Resources/public/css/admin.css'output='bundles/yourbundle/css/admin_style.css'%}<link href="{{ asset_url }}?{{ AssetVersion }}" rel="stylesheet" type="text/css">{% endstylesheets %}