0

I use Symfony 2.7 with the internal web server (installed with composer). I want to use different resources (css, js, images, fonts) in my twig files with a path like this

<link href="/css/style.css" rel="stylesheet">

In this case I get an error message: No route found for "GET /css/style.css"

I copied the resources to the web folder /web/css etc. so the files should be in the right place. How can I configure the routing that it picks up the resources without an error?

Thanks

Bernhard

Bernie
  • 39
  • 7
  • Take a look at this [chapter](http://symfony.com/doc/current/book/templating.html#linking-to-assets) – Artamiel Oct 13 '15 at 12:22

2 Answers2

0

You should try with

<link href="{{ asset('/css/style.css')}}" rel="stylesheet">
BENARD Patrick
  • 30,363
  • 16
  • 99
  • 105
  • Thanks a lot that fixed it, just one more question: Within a css I have something like that: `background-image:url(/images/icons/loader.gif)` How can I handle this links in the stylesheet? – Bernie Oct 13 '15 at 12:34
  • I suggest you to read this question, very long but usefull : http://stackoverflow.com/questions/9500573/path-of-assets-in-css-files-in-symfony-2 – BENARD Patrick Oct 13 '15 at 13:51
0

In your base.html.twig, you should add this:

{% block stylesheets %}
        <link href="{{ asset('css/main.css') }}" rel="stylesheet" />
{% endblock %}
scoolnico
  • 3,055
  • 14
  • 24