我正在用 Symfony 进行我的第一个项目,我创建了我的第一个控制器。并出现此错误。
我试过了
作曲家更新
我遇到了同样的问题! 更新 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');
}
}
Run Code Online (Sandbox Code Playgroud)
index.html.twig文件只有一个<h1> test </h1>就可以了
是什么让这个问题出现?以及如何在不删除项目并重新创建的情况下修复它!谢谢
Sne*_*ekk 17
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');
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4184 次 |
| 最近记录: |