https://github.com/thecodingmachine/laravel-universal-service-provider
This bridge allows Laravel applications to use service providers as defined in container-interop/service-provider
https://github.com/thecodingmachine/laravel-universal-service-provider
Last synced: about 1 month ago
JSON representation
This bridge allows Laravel applications to use service providers as defined in container-interop/service-provider
- Host: GitHub
- URL: https://github.com/thecodingmachine/laravel-universal-service-provider
- Owner: thecodingmachine
- Created: 2016-03-06T21:55:34.000Z (about 10 years ago)
- Default Branch: 1.0
- Last Pushed: 2017-09-21T13:30:10.000Z (over 8 years ago)
- Last Synced: 2025-10-20T06:24:50.502Z (5 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 2
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# container-interop/service-provider bridge for Laravel
Import `service-provider` as defined in `container-interop` into a Laravel application.
## Usage
### Installation
Add the package in composer:
```sh
composer require thecodingmachine/laravel-universal-service-provider ^1.0
```
Add `\TheCodingMachine\Laravel\ContainerInteropBridgeServiceProvider` in your `config/app.php` file.
**config/app.php**
```php
[
//...
TheCodingMachine\Laravel\ContainerInteropBridgeServiceProvider::class
],
//...
];
```
### Usage using thecodingmachine/discovery
The bridge will use thecodingmachine/discovery to automatically discover the universal service providers of your project. If the service provider you are loading publishes itself
on thecodingmachine/discovery, then you are done. The services declared in the service provider are available in the Laravel container!
### Usage using manual declaration
If the service provider you are using does not publishes itself using thecodingmachine/discovery, you will have to declare it manually in the `container-interop-service-providers` key of your `config/app.php' file.
Set the service provider fully qualified class name in the parameter `container-interop-service-providers`:
**config/app.php**
```php
[
GlideServiceProvider::class
]
];
```
Now, you can do : `$app->make('glide')`
## Disabling discovery
You can disable discovery using the `container-interop-service-provider-enable-discovery` setting:
**config/app.php**
```php
false
];
```
##Purging the cache
The Laravel service provider in this package is a **deferred provider**.
Laravel compiles and stores a list of all of the services supplied by this provider. Then, only when you attempt to resolve one of these services does Laravel load the service provider.
If you add a new service to one of the universal service providers, you will need to purge the "compiled" services. You can do this with this command line:
```php
php artisan clear-compiled
```