Symfony 4:文件已找到,但 class 不在其中

Symfony 4 : The file was found but the class was not in it

这个问题已经被问了很多,但是 none 的答案可以帮助我。 我正在对过时的 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/"
    }
}

这可能是一件简单的事情,但无法弄清楚,也没有在网上找到答案。

如有任何帮助,我们将不胜感激。我希望我提供了足够的信息。

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

"App\Controller\BrandAcadamyFeedback\" 应该是 App\Controller\BrandAcademyFeedback\

对不起。