我已经开始了一个Symfony2教程,并使用Intellij Idea创建了一个默认项目。
当我尝试运行该项目时,出现以下错误:
Fatal error: Class 'Symfony'Bundle'FrameworkBundle'Controller'Controller' not found in
C:'Users'[...]'SymfonyTraining'src'AppBundle'Controller'DefaultController.php
on line 10
它与以下文件相关:
<?php
namespace AppBundle'Controller;
use Symfony'Bundle'FrameworkBundle'Controller'Controller;
use Sensio'Bundle'FrameworkExtraBundle'Configuration'Route;
use Symfony'Component'HttpFoundation'Request;
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
*/
public function indexAction(Request $request)
{
// replace this example code with whatever you need
return $this->render('default/index.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'),
]);
}
}
?>
我找到的所有答案都是关于缺少命名空间或使用或拼写错误,但似乎不是。
知道吗?
(也许这只是一些我没有看到的明显的东西)
您需要更新自动加载机。您可以使用"转储自动加载"来执行此操作,而无需进行安装或更新因此,请尝试执行此命令:
作曲家转储自动加载