Where can you put a Service Provider Class in Laravel?

I want to create a server provider in Laravel.

I want this service provide to live under its own namespace.

PathToMyAwesomeServiceProvider

Where should I put this class? Normally I'd drop a custom class in

app/models

However, app/models isn't added as an autoload source until after app/start/global.php executes. This is too late for a service provider, as all service providers are registered in bootstrap/start.php .

Is there a way to create a service provider without placing the class in composer's vendor folder or monkeying with your composer.json classmap?

Put another way, is there a location where Laravel will autoload classes from prior to bootstrap/start.php being loaded that doesn't require additional composer configuration.

(For the inevitable "why don't you justs", the reason I want to avoid composer is I'm trying to figure out the bare minimum code and configuration needed for a service provider in Laravel)


you dont need to modify anything inside vendor. You only need to define one of the possible autoload types for your new class or directory inside the composer.json of your project.

https://getcomposer.org/doc/04-schema.md#autoload

as alternate you can directly use a plain php implementation of the autoloading https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md

链接地址: http://www.djcxy.com/p/88640.html

上一篇: 作曲家更新之前,Laravel 4.2包括提供者

下一篇: 你在哪里可以在Laravel上放置一个服务提供者类?