Symfony FileLoaderLoadException 但 class 确实存在

Symfony FileLoaderLoadException but class does exist

我从昨天开始就一直在使用 Symfony 3,但在自动连接方面遇到了困难。

由于某些原因,FileLoader 无法找到我的 class,而它确实存在。

在 services.yml 我有以下内容:

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

    RideShare\Infrastructure\:
        resource: '../../src/RideShare/Infrastructure/*'

文件夹 src/RideShare/Infrastructure/EventStore/Doctrine 中有文件 DoctrineEventStore.php,内容如下:

<?php

namespace RideShare\Infrastructure\EventStore\Doctrine;

use ...;

class DoctrineEventStore extends EntityRepository implements EventStore

但是当我尝试 运行 php bin/console 时,出现以下异常:

Symfony\Component\Config\Exception\FileLoaderLoadException: 
Expected to find class "RideShare\Infrastructure\EventStore\Doctrine\DoctrineEventStore" in file "[....]src/RideShare/Infrastructure/EventStore/Doctrine/DoctrineEventStore.php" while importing services from resource 
"../../src/RideShare/Infrastructure/*", but it was not found! Check the namespace prefix used with the resource in [...]/app/config/services.yml (which is being imported from "[...]/app/config/config.yml"). in [...]/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php on line 179

据我所知,这个声明是正确的,但我在 Whosebug 或 Symfony 文档中没有看到这样的问题,而且我不知道为什么它会失败。

可在 Github 找到完整代码。

问题是 EventStore 接口的命名空间有误。