我在 app 文件夹中创建了一个库文件夹来添加我的应用程序库。我已经更新了应用程序配置文件和 composer.json 以自动加载该文件夹,但是当我运行命令时,composer dump-autoload
我得到下一个错误:
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'App\\Libraries\\Search\\SearchServiceProvider' not found","file":"D:\\Users\\Miguel Borges\\Documents\\Trabalhos\\Tese\\portal\\bootstrap\\compiled.php","line":4130}}PHP Fatal error: Class 'App\Libraries\Search\SearchServiceProvider' not found in D:\Users\Miguel Borges\Documents\Trabalhos\Tese\portal\bootstrap\compiled.php on line 4130 [Finished in 1.1s with exit code 255]
我的应用程序文件夹树:
app
| ...
+ libraries
| + search
| | - Search.php
| | - SearchFacade.php
| | - SearchServiceProvider.php
| + lib2
| | - ...
| + lib3
| | - ...
| | - Theme.php
| - ...
- filters.php
- routes.php
搜索服务提供者.php
namespace App\Libraries\Search;
use Illuminate\Support\ServiceProvider;
class SearchServiceProvider extends ServiceProvider {
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app['search'] = $this->app->share(function($app)
{
return new Search;
});
}
}
作曲家.json
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/libraries",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
// ,
// "psr-0": {
// "app": "app/libraries"
// }
},
基本上,我需要自动加载“库”文件夹中的所有库。