I am working on a Laravel 5 application and now the code of the application is supposed to be re-used in multiple laravel 5 applications which is why I am creating a composer package and then I would like to install this package in any number of laravel 5 applications to have the same functionality and build over it too.
I am new to composer package development and especially hooking packages into Laravel 5 using Service Providers. So far I have learnt that if I use a service provider as the one below, I will be able to use the routes in the laravel 5 application:
<?php
namespace Uppdragshuset\AO\Tenant;
use Illuminate\Support\ServiceProvider;
class TenantServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
include __DIR__.'/routes.php';
}
}
Now to make this work, I just require the package via composer into any brand new Laravel 5 installation and then I just need to updated the provider's array in app.php
with this:
Uppdragshuset\AO\Tenant\TenantServiceProvider::class
This makes sense to me and works too. But now the package that I am developing also has dependencies of its own and many of the those dependency packages also have laravel 5 service providers included so I have to manually include all of them in the laravel5 installations to make them work.
But I am guessing there must be a way to register these dependent service providers in the package that I am creating itself somehow so that I just need to register the one provider I mentioned above. The problem is I don't know how to do this and cannot find a similar reference anywhere. How to register multiple service providers from the composer package itself?