symfony - 加载时找不到类控制器
问题描述
我正在使用 Symfony 进行我的第一个项目,我创建了我的第一个控制器。并出现此错误。
我尝试过了
作曲家更新
我遇到了同样的问题! 更新作曲家时出现的问题
这是TestController.php的代码
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class TestController extends Controller {
/**
* @Route("/")
* @Method ({"GET"})
*/
public function index()
{
//return new Response('<html><body>Hello world</body></html>');
return $this->render('articles/index.html.twig');
}
}
<h1> test </h1>
index.html.twig文件只有一个
是什么让这个问题出现?以及如何在不删除项目并重新创建它的情况下修复它!谢谢
解决方案
Symfony\Bundle\FrameworkBundle\Controller\Controller
自 v4.2.0起已弃用,自 v5.0.0起已删除,请Symfony\Bundle\FrameworkBundle\Controller\AbstractController
改用。
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class TestController extends AbstractController {
/**
* @Route("/", methods={"GET"})
*/
public function index()
{
//return new Response('<html><body>Hello world</body></html>');
return $this->render('articles/index.html.twig');
}
}
推荐阅读
- swift - iOS Firebase Twitter 登录每次都请求权限
- php - PHP Imagick 无法使用 Microsoft EDGE 生成的 pdf
- mysql - 如何更改 sequelize 内连接输出格式
- javascript - 为什么阻塞事件循环不会阻塞css动画?
- c# - 如何将依赖项注入静态类
- javascript - Angular 4(业力)测试输入值到输入字段
- javascript - 将 Vueitfy 用户界面嵌入现有网站
- reactjs - React Js 日期范围选择器
- php - 奇怪的 Magento 500 内部服务器错误
- android - 如何从 Firestorage 中删除特定文件?