0

I have the same problem as the guy who asked this question but since i use symfony 4, it can't be because of not specifying the bundle.

At first, i was trying to load a css file in my template without assetic, using :

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

I thought it was enought since that's what the documentation says, but the css is not loading and i have an html file (not actually displayed) instead.

The html file is a symfony error page saying :

No route found for "GET /css/layer.css"

At first i thought it may be a domain error, so i specified it :

<link rel="stylesheet" href="http://localhost:8000/css/layer.css" />

but nothing changed.

I also tried to load the css with assetic, using :

<link rel="stylesheet" href="{{ asset('css/layer.css') }}" />

but i got the exact same error. (assetic builded the same route)

The file is : /css/layer.css.

I don't know what i'm doing wrong. Can you help ?

Hollyol
  • 827
  • 1
  • 13
  • 25

2 Answers2

1
<link rel="stylesheet" href="css/layer.css">

Try this one.Remove the '/' in your path and store the html file and css folder in a common folder.

vasanths294
  • 1,457
  • 2
  • 13
  • 29
1

Before using the asset, you need to copy the assets to the web folder with the command assets:install

like you see here:

The assets:install command is one of the trickiest things for Symfony newcomers. This command is used to install the web assets (CSS, JavaScript, images) for the production application. When executed without options, the command copies into web/ all the files found in the Resources/public/ directories of your application and bundles.

fab
  • 1,189
  • 12
  • 21