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

10,098

Ensure that the css - file is in the public folder of the bundle where it's used. Then check if it is installed (copy in Web folder or as symlink - via php bin/console assets:install --symlink) Then inside your twig file use

<link rel="stylesheet" href="{{ asset(path to css file) }} ">

If the site is already online make sure to delete cached twig files inside app/cache/prod/.

Hope it helps.

Share:
10,098
dario_ramos
Author by

dario_ramos

Updated on June 17, 2022

Comments

  • dario_ramos
    dario_ramos almost 2 years

    I migrated a Symfony 2 website to a shared hosting which uses CPanel. After solving many issues, I'm stumped on this one. It seems that Symfony cannot find the resources in the assets directory (web/assets).

    I opened the log and found a bunch of errors like the one in the title. I tried clearing the cache and setting usecontroller = true in config.yml. Any suggestion?

    Update: Here's a sample error line:

    [2015-10-04 03:19:58] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /assets/css/pgwslider.css"" at /home/afianzar/public_html/htdocs/app/cache/prod/classes.php line 1883 {"exception":"[object] (Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for \"GET /assets/css/pgwslider.css\" at /home/afianzar/public_html/htdocs/app/cache/prod/classes.php:1883, Symfony\Component\Routing\Exception\ResourceNotFoundException: at /home/afianzar/public_html/htdocs/app/cache/prod/appProdUrlMatcher.php:994)"} []

    Update 2: In base.html.twig, here's how pgwslider.css is included:

    <link rel="stylesheet" href="/assets/css/pgwslider.css" />