Search code examples
laravellaravel-4packageservice-provider

Laravel selfregistering ServiceProvider


In Laravel 4.2 is it possible to create a package which automatically registers the ServiceProvider without the user adding the path manually to the app.php file?

This way one could just run composer update after adding a package to the composer.json file and would be ready to go.


Solution

  • I think that there is no way to register your main service provider than putting it in the app.php file. In fact you can, but it will always require something from the developer. You can't get away with it with a simple composer update.

    You can register sub service providers with App::register('MyApp\Providers\MyServiceProvider'); inside your package.