我在app目录中使用自定义文件夹,其中包含Billing,Exceptions,Repositories等。这是我的目录结构......
app
-iw
-Billing
-BillingInterface.php
-StripeBilling.php
-Exceptions
-Repositories
-macros.php
composer.json
"psr-4": {
"iw\\" : "app/iw"
},
运行命令composer dump-autoload -o
类
// app/iw/BillingInterface.php (location)
<?php namespace iw\Billing;
interface BillingInterface {}
和
// app/iw/StripeBilling.php (location)
<?php namespace iw\Billing;
class StripeBilling {
public function bill()
{
dd('billing');
}
}
我发现找不到类错误,即使我注意到vendor/composer/autoload_ps4.php
没有使用这个新文件夹进行更新。请帮忙。感谢
答案 0 :(得分:2)
添加&#34; app / iw&#34;在&#34; classmap&#34;。
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/iw"
],
"psr-4" : {
"iw\\" : "app/iw"
}
}
并运行
composer dump-autoload -o
答案 1 :(得分:0)
我试过这个json文件并且它有用......
"autoload": {
"psr-4": {"iw\\" : "app/iw" },
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
}
但请在自动加载部分中添加"psr-4": {"iw\\" : "app/iw" }
之后建议原因。