[英]Laravel composer dump-autoload not applying new PSR-4 structure
My PSR4 structure isn't registering when I composer dump-autoload
. composer dump-autoload
时,我的PSR4结构未注册。 This my composer, the entry is src/Booksmart : 这是我的作曲家,条目是src / Booksmart:
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/controllers/Api",
]
},
"psr-4": {
"Booksmart\\": "src/Booksmart"
},
and this is my directory structure: 这是我的目录结构:
src/
Booksmart/
Advance/
Advance.php
The Advance.php looks like this: Advance.php看起来像这样:
<?php
namespace Booksmart\Advance
class Advance
{
}
My vendor/composer/autoload_psr4.php
doesn't show the new entry for my Booksmart namespace though, and is definitely not loading the Advance.php class. 我的
vendor/composer/autoload_psr4.php
/composer/autoload_psr4.php并未显示我的Booksmart命名空间的新条目,并且绝对不会加载Advance.php类。 This seems so simple to screw up, what am I missing? 这看起来很简单,我想念什么?
PSR-4 must be inside autoload: PSR-4必须位于自动加载程序内:
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/controllers/Api",
],
"psr-4": {
"Booksmart\\": "src/Booksmart"
},
},
I thing you don't need compose. 我认为您不需要撰写。 In my case I am paying namespace like this in "Advance" class.For Example
namespace App\\src\\Bookmart\\Advance
. 就我而言,我在“ Advance”类中为此支付了命名空间。例如,
namespace App\\src\\Bookmart\\Advance
。 And then in the dependency class use App\\src\\Bookmart\\Advance;
然后在依赖项类中
use App\\src\\Bookmart\\Advance;
. 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.