我从昨天起就开始使用Symfony 3,但是自动接线很困难。
由于某种原因,FileLoader在找到我的课时却无法找到它。
在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
我认为这个声明是正确的,我在stackoverflow或Symfony文档中都没有看到这样的问题,我也不知道它为什么会失败。
可在Github找到完整代码。
答案 0 :(得分:0)
问题是EventStore接口的命名空间错误。