我已经开始使用Symfony2教程,并使用Intellij Idea创建了一个默认项目。Symfony2:未找到控制器类(默认情况下为生成的文件)
当我尝试运行该项目,我收到以下错误:
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').'/..'),
]);
}
}
?>
所有我找到的答案是关于失踪的命名空间或使用,或错别字,但似乎并不是这样。
有什么想法?
(也许它只是一些很明显我没有看到)
你怎么跑这个项目?您是否正在使用一些IDE函数来“运行项目”,以便在浏览器中打开该特定文件,或者您是否正在使用某些正确提供app.php/app_dev.php的Web服务器? – JimL
您是否已经安装了作曲家,以便自动加载器准备好? – olibiaz
我使用IDE的选项“运行项目”,因为我在服务器上遇到了问题,而且我想一步一步去那里。 我安装了作曲家,有什么具体的要做的自动装载机? – DarksteelPenguin