Symfony 4:找到了文件但是课程没有

时间:2018-04-06 06:54:41

标签: symfony routes composer-php symfony4 autoloader

这个问题已被问到很多,但答案都没有帮助我。 我正在对一个过时的symfony 3进行symfony 4升级。我删除了所有的包以纠正文件架构,但我可能搞砸了。

在命令行中执行bin / console我收到此错误:

The autoloader expected class "App\Controller\BrandAcadamyFeedback\FeedbackAnswerController" to be defined in file "/Users/username/www/myfolder/sf/vendor/composer/../../src/Controller/BrandAcadamyFeedback/FeedbackAnswerController.php". The file was found but the class was not in it, the class name or namespace probably has a typo in /Users/username/www/myfolder/sf/config/services.yaml (which is loaded in resource "/Users/username/www/myfolder/sf/config/services.yaml").

以下是我的文件:

Services.yaml

imports:
- { resource: security.yaml }

parameters:
   locale: 'en'

services:
    _defaults:
        autowire: true      
        autoconfigure: true 
        public: false

    App\:
        resource: '../src/*'
        exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'

    App\Controller\:
        resource: '../src/Controller/*'
        tags: ['controller.service_arguments']

FeedbackAnswerController.php

namespace App\Controller\BrandAcadamyFeedback;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\ConstraintViolationList;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\Routing\Annotation\Route;
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\Annotations\Post;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use App\Controller\API\APIController;

/**
* Controller for Entity\BrandAcadamyFeedback\FeedbackAnswer.
*
* @View
* @Route("/api/feedback-answer")
*/
class FeedbackAnswerController extends APIController
{
}

Annotations.yaml

controllers:
    resource: ../../src/Controller/
    type: annotation

Composer.json

"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
}

这可能很容易,但无法弄明白,也无法在网上找到答案。

任何帮助都将受到高度赞赏。我希望我提供了足够的信息。

1 个答案:

答案 0 :(得分:0)

感谢Cerad评论我去了四倍检查我的控制器的命名空间,我的应用程序的文件夹名称中确实存在错误拼写。

"应用软件\控制器\ BrandAcadamyFeedback \"应该是App \ Controller \ BrandAcademyFeedback \

对不起。