Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Symfony2 assetic results in 404

I can't seem to get assetic to work with me.

Here is my assetic config in my config.yml file

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ FOSUserBundle, MyUserBundle ]
    filters:
        cssrewrite: ~

I have created a bundle that extends the FOSUserBundle. I've overridden the registration template and am trying to include my own css.

// MyUserBundle/Resources/views/Registration/register_content.html.twig

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

My bundle has the following structure:

/MyUserBundle
    ...
    /Resources 
        ...
        /public
            /css
                signup.css

I always get a 404 though.

http://myproject.dev/css/494d9ed_part_1_signin_1.css 404 Not Found.

I get the following exception thrown:

No route found for "GET /css/494d9ed_part_1_signin_1.css"

I've published the assets so it also lives in

/MyProject
    /web
        /bundles
            /myuser
                /css
                    signin.css

What am I doing wrong?

like image 376
David Avatar asked Mar 10 '14 14:03

David


Video Answer


1 Answers

Try with this syntax:

{% stylesheets filter='cssrewrite' '@MyUserBundle/Resources/public/css/*' %}
    <link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
{% endstylesheets %}

and then on the command line:

php app/console cache:clear
php app/console assets:install --symlink
php app/console assetic:dump

In the DEV environment it should work without the assetic:dump command.

like image 130
Francesco Casula Avatar answered Sep 25 '22 15:09

Francesco Casula