简体   繁体   English

加载“App\\Controller\\StudentController”时找不到类“Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller”

[英]Class "Symfony\Bundle\FrameworkBundle\Controller\Controller" not found while loading "App\Controller\StudentController"

Hi I'm fresher for symfony .嗨,我是 symfony 的新手。 when i execute the below code it will show error.i installed all the assets of symfony.help me to clear this..!当我执行下面的代码时,它会显示错误。我安装了 symfony 的所有资产。帮我清除这个..!

<?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 StudentController extends Controller
{
    /**
     * @Route("/")
     * @Method({"GET"})
     */
    public function index()
    {
        //  return new Response(
        //   '<html><body><h1>HI,Welcome to Tamilnadu</h1></body></html>'
        // );
        return $this->render('student/index.html.twig');
    }
}

I just put "hello" in (student/index.html.twig),and i commented the basic response function and want to run the return this function.我只是在 (student/index.html.twig) 中放了“hello”,我评论了基本的响应函数并希望运行返回这个函数。

Try this:尝试这个:

 /**
 * @Route("/", name="index")
 * @return Response
 */
public function index():Response{
    return $this->render('student/index.html.twig');
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到symfony \\ bundle \\ frameworkbundle \\ controller - symfony\bundle\frameworkbundle\controller not found PHP Xdebug,致命错误:在/中找不到类&#39;Symfony \\ Bundle \\ FrameworkBundle \\ Controller \\ Controller&#39; - PHP Xdebug, Fatal error: Class 'Symfony\Bundle\FrameworkBundle\Controller\Controller' not found in / 调用受保护的方法Symfony \\ Bundle \\ FrameworkBundle \\ Controller \\ Controller :: generateUrl() - Call to protected method Symfony\Bundle\FrameworkBundle\Controller\Controller::generateUrl() 自动完成不正确,Controller类中的$ this-&gt; getRequest引用了Symfony \\ Bundle \\ FrameworkBundle \\ Controller \\ Request - Incorrect autocomplete, $this->getRequest in Controller class is referencing to Symfony\Bundle\FrameworkBundle\Controller\Request Symfony:渲染必须与Symfony \\ Bundle \\ FrameworkBundle \\ Controller \\ AbstractController :: render兼容 - Symfony: Render must be compatible with Symfony\Bundle\FrameworkBundle\Controller\AbstractController::render Symfony2:扩展FrameworkBundle控制器 - Symfony2 : extending FrameworkBundle Controller 无法在扩展Symfony \\ Bundle \\ FrameworkBundle \\ Controller \\ Controller的控制器中访问Symfony2容器 - Unable to access Symfony2 container in controller extending Symfony\Bundle\FrameworkBundle\Controller\Controller 加载时未找到类控制器 - Class Controller not found while loading Symfony 2:在控制器中找不到类 - Symfony 2: Class not found in Controller 找不到symfony控制器类 - symfony controller class not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM