I\'m creating a package for Laravel and I\'ve defined the Notification package (https://github.com/edvinaskrucas/notification) as a dependency for my package.
In /workbe
You can use the alias() method on the app to register an alias, but I would consider having your package users register aliases and service providers themselves in the install process. It's a good way of keeping track of the external code that you're using, and a nice way of pulling components out to test things.
Personal opinion of course. :)
Dayle
I had the same problem. I had a dependency in a package and didn't want to bother the user with these dependencies, for it was a dependency in a dependency. So this is the solution. Hope it will help you!
public function register()
{
/*
* Register the service provider for the dependency.
*/
$this->app->register('LucaDegasperi\OAuth2Server\OAuth2ServerServiceProvider');
/*
* Create aliases for the dependency.
*/
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('AuthorizationServer', 'LucaDegasperi\OAuth2Server\Facades\AuthorizationServerFacade');
$loader->alias('ResourceServer', 'LucaDegasperi\OAuth2Server\Facades\ResourceServerFacade');
}
During package development you should add your package service provider in composer.json file as in the code below. For additional information please consult at Laravel's Package Discovery.
"extra": {
"laravel": {
"providers": [
"Barryvdh\\Debugbar\\ServiceProvider"
],
"aliases": {
"Debugbar": "Barryvdh\\Debugbar\\Facade"
}
}
},