我在类的类加载方面遇到问题。
安装我的包后,它找不到该类,这是它的错误消息:
Illuminate\Contracts\Container\BindingResolutionException : Target class [SundayIT\ChatbotAdmin\Commands\DBM_RealtimeStats] does not exist.
这是自动加载器错过的类的前几行:
<?php
namespace SundayIT\ChatbotAdmin\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class DBM_RealtimeStats extends Command
这是包的 composer.json
文件的相关部分
"autoload": {
"psr-4": {
"SundayIT\\ChatbotAdmin\\": "src/"
}
},
我错过了什么?我尝试在这里检查其他问题,但没有找到解决方案。谢谢
最佳答案
根据PSR-4 standard类名不应包含下划线。
Underscores have no special meaning in any portion of the fully qualified class name.
这就是为什么将类重命名为 DbmRealtimeStats
并将文件重命名为 DbmRealtimeStats.php
有效(如前所述 here )。
关于laravel - Composer 自动加载器找不到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58033250/