Class 加载时找不到控制器
Class Controller not found while loading
我正在使用 Symfony 开发我的第一个项目,我创建了我的第一个控制器。然后出现这个错误。
problem image
我试过
composer update
我遇到了同样的问题!
The problem that appear when i update the composer
这里是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');
}
}
index.html.twig 文件只有 <h1> test </h1>
出现这个问题的原因是什么?以及如何在不删除项目并重新创建项目的情况下修复它!
谢谢
Symfony\Bundle\FrameworkBundle\Controller\Controller
已经是 deprecated since v4.2.0 and removed since 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');
}
}
我正在使用 Symfony 开发我的第一个项目,我创建了我的第一个控制器。然后出现这个错误。
problem image
我试过
composer update
我遇到了同样的问题! The problem that appear when i update the composer
这里是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');
}
}
index.html.twig 文件只有 <h1> test </h1>
出现这个问题的原因是什么?以及如何在不删除项目并重新创建项目的情况下修复它! 谢谢
Symfony\Bundle\FrameworkBundle\Controller\Controller
已经是 deprecated since v4.2.0 and removed since 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');
}
}