dougong2005
2014-08-29 01:01
浏览 145
已采纳

Laravel composer dump-autoload没有应用新的PSR-4结构

My PSR4 structure isn't registering when I composer dump-autoload. This my composer, the entry is 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:

<?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. This seems so simple to screw up, what am I missing?

图片转代码服务由CSDN问答提供 功能建议

当我 composer dump-autoload 时,我的PSR4结构没有注册。 这是我的作曲家,条目是src / Booksmart:

 “autoload”:{
“classmap”:[
“app / commands”,
“app / 控制器“,
”app / models“,
”app / database / migrations“,
”app / database / seeds“,
”app / tests / TestCase.php“,
”app / controllers /  Api“,
] 
},
”“psr-4”:{
“Booksmart \\”:“src / Booksmart”
},
   
 
  

这是我的目录结构:

  src / 
 Booksmart / 
 Advance / 
 Advance.php 
   \  n 
 

Advance.php如下所示:

 &lt;?php 
namespace Booksmart \ Advance 
 
class Advance 
 {
 
}  
   
 
 

我的 vendor / composer / autoload_psr4.php 虽然没有显示我的Booksmart命名空间的新条目,但绝对不会加载 Advance.php类。 这似乎很容易搞砸了,我错过了什么?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douxin9135 2014-08-29 01:05
    已采纳

    PSR-4 must be inside autoload:

    "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"
        },
    
    },
    
    打赏 评论
  • douer9399 2017-08-26 08:26

    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. And then in the dependency class use App\src\Bookmart\Advance;.

    打赏 评论

相关推荐 更多相似问题