Symfony application does not load css files

1

I recently started working with symfony applications and every day I have new problems that I have to solve, one of them is that my main view of the application does not load the files .css , I already have them defined within the block: {% block stylesheets %} And this is how the references:   <link rel="stylesheet" type="text/css" href="{{ asset('bundles/staticpages/css/lib/font-awesome.min.css') }}">  I do not know if I should also install some plugin or library necessary to the web to load correctly.

Could someone tell me how to fix it?

Thank you.

    
asked by Amoliu 19.10.2017 в 18:01
source

1 answer

1

Look which is the url that generates, is very likely to be something like web/bundle/staticpages/css/lib/font-awesome.css which would give a 404 if it does not exist.

Unless you have a very complex project with several bundles and other herbs, it's much simpler to place the assets in the web/ folder.  Within it you will find a directory for css , another for js , etc.

In your particular case I would recommend placing the file font-awesome.min.css in web/css/ , in the view references as <link href="{{ asset(css/font-awesome.min.css) }}" ... /> . More info at symfony best practices

    
answered by 19.10.2017 в 22:02