【发布时间】:2021-05-05 02:00:44
【问题描述】:
我正在从 Scrach Symfony 学习 5.0.1 版本。 我使用 --full 选项创建了一个项目。 Annotations 包已经安装。
这是我的错误:
C:\wamp64\www\crowdin\group-834932\crowdin\config/routes../../src/Controller/ 中不存在类“1\HomeController”(从“C: \wamp64\www\crowdin\group-834932\crowdin\config/routes/annotations.yaml")。确保已安装并启用注释。
这是我的 HomeController(由制造商制作):
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
/**
* @Route("/home", name="home")
*/
public function index(): Response
{
return new Response('<h1>Home Page</h1>');
}
}
以及 annotations.yaml 文件:
controllers:
resource: ../../src/Controller/
type: annotation
kernel:
resource: ../../src/Kernel.php
type: annotation
为什么它不起作用?我安装了所有需要的软件包。我很好地遵循了配置过程。 你能帮帮我吗?
【问题讨论】:
-
类“1\HomeController”?那个1是从哪里来的?也许你的控制器文件中有一个控制代码?
-
由于某种原因,您在
C:\wamp64\www\crowdin\group-834932\crowdin\config/routes../../src/Controller/中似乎缺少/,应该类似于/routes/.. -
您可以尝试清除缓存吗?
rm -rf var/cache/*
标签: symfony symfony5 symfony-routing