Create Shared Service
You can create a package, and all your projects will register it as a dependency. Use this package to override all dependency configuration files.
In your shared service, you need to create a service provider for each of the service providers you want to override. Extend the dependency service provider and use the register method to load your own configuration file, not the dependency configuration file.
For instance:
class SharedPermissionServiceProvider extends PermissionServiceProvider { public function register() { if (isNotLumen()) { $this->mergeConfigFrom( __DIR__.'/../config/permission.php', 'permission' ); } $this->registerBladeExtensions(); } }
If you use Laravel 5.5 or higher, you may need to opt out of automatically detecting packages for each of your dependencies in order to prevent the use of dependency service providers. Register your service providers in composer.json instead.
If you use Laravel 5.4 or lower, or if you override a service provider that does not use automatic discovery, remove the service providers of your dependencies from your config/app.php and add your own.
source share