Symfony4内核找不到自动加载的类

时间:2019-04-03 07:32:18

标签: symfony4 autoload

对于复制的库,我有一个单独的结构:

bundles/lightsaml/lightsaml/src
bundles/lightsaml/sp-bundle/src
bundles/lightsaml/symfony-bridge/src
bundles/mdanter/ecc/src
bundles/robrichards/xmlseclibs/src

composer.json中:

"autoload": {
    "psr-4": {
        "App\\": "src/",
        "LightSaml\\SymfonyBridgeBundle\\": "bundles/lightsaml/symfony-bridge/src",
        "LightSaml\\SpBundle\\": "bundles/lightsaml/sp-bundle/src",
        "LightSaml\\": "bundles/lightsaml/lightsaml/src",
        "Mdanter\\": "bundles/mdanter/ecc/src",
        "RobRichards\\": "bundles/robrichards/xmlseclibs/src"
    }
},

还尝试了composer.json的这种变体:

        "LightSaml\\": [
            "bundles/lightsaml/symfony-bridge/src",
            "bundles/lightsaml/lightsaml/src",
            "bundles/lightsaml/sp-bundle/src"
        ],

config/bundles.php中:

LightSaml\SymfonyBridgeBundle\LightSamlSymfonyBridgeBundle::class => ['all' => true],
LightSaml\SpBundle\LightSamlSpBundle::class => ['all' => true],

但是,我收到以下错误:

***ClassNotFoundException***

Attempted to load class "LightSamlSymfonyBridgeBundle" from namespace "LightSaml\SymfonyBridgeBundle".
Did you forget a "use" statement for "LightSaml\SymfonyBridgeBundle\LightSamlSymfonyBridgeBundle"?

该项目在docker中进行了干净的重建。缓存已清除等。

我在做什么错了?

1 个答案:

答案 0 :(得分:0)

解决方案是use classmaps(打开 optimize-autoloader )。