简体   繁体   中英

stylesheet not found with asset in symfony

I am currently learning symfony (v. 4) and trying to include a .css file in a template. However, I get this mistake: GET http://localhost:8000/css/app.css net:: ERR_ABORTED

My template ( src/templates/index/tracking.html.twig ):

{% extends' base.html.twig' %}

{% block stylesheets %}
    <link rel= "stylesheet" href="{{ asset ('css/app.css') }}" />
{% end block %}
...

My controller ( src/Controller/TrackingController.php ):

<?php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use App\Entity\Time;

class TrackingController extends Controller {
    public function index () {
        return $this->render ('index/tracking.html.twig');
    }
}

My CSS file is located under assets/css/app.css . What am I doing wrong? How can I integrate the CSS file correctly?

如果不使用Webpack-Encore,则css文件应位于“ public / css”文件夹中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM