我正在尝试将 symfony flex 与捆绑包一起使用。
我有这个目录结构
/
src/
AppBundle/
AppBundle.php
# Many classes
Kernel.php
我想用这个命名空间加载 Kernel.php 类,App
并用命名空间加载 AppBundle 中的类AppBundle
。
我尝试了许多作曲家配置,但无法加载它们。
"psr-4": {
"AppBundle\\": "src/AppBundle/",
"App\\": "src/"
}
但是我遇到了这样的错误:
Expected to find class "App\AppBundle\AppBundle" in file "/var/www/vhosts/flex/src/AppBundle/AppBundle.php"
更新
src/Kernel.php 类具有不同的命名空间,我无法更改它,因为其他类使用它,命名空间是App
. 一些脚本使用use App\Kernel
src/AppBundle/AppBundle.php
类有这个命名空间AppBundle
有办法做到这一点吗?
更新 2
我整理了一下:
"autoload": {
"psr-4": {
"AppBundle\\": "src/AppBundle/"
},
"classmap": [
{ "App\\Kernel": "src/Kernel.php" }
]
},