Symfony4 内核找不到自动加载 类
Symfony4 Kernel doesn't find autoloaded classes
我有一个用于复制库的单独结构:
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 中完全重建。清除缓存等
我做错了什么?
解决方案是 use classmaps(开启 optimize-autoloader)。
我有一个用于复制库的单独结构:
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 中完全重建。清除缓存等
我做错了什么?
解决方案是 use classmaps(开启 optimize-autoloader)。