Symfony-inspired package to list available services in Laravel IoC Container. Works with Laravel 5.4-11.x.
+--------------------------------------------------------------+-------------------------------------------------------------+--------+-------+
| Service ID | Class | Shared | Alias |
+--------------------------------------------------------------+-------------------------------------------------------------+--------+-------+
| IonBazan\Laravel\ContainerDebug\Tests\IContainerContractStub | IonBazan\Laravel\ContainerDebug\Tests\ContainerConcreteStub | No | No |
| IonBazan\Laravel\ContainerDebug\Tests\SingletonService | IonBazan\Laravel\ContainerDebug\Tests\SingletonService | Yes | No |
| alias.b | alias for "service.b" | No | Yes |
| alias.c | alias for "service.c" | No | Yes |
| service.a | IonBazan\Laravel\ContainerDebug\Tests\ServiceStubA | No | No |
| service.b | IonBazan\Laravel\ContainerDebug\Tests\ServiceStubB | No | No |
| service.c | IonBazan\Laravel\ContainerDebug\Tests\ServiceStubC | No | No |
| service.d | N/A | No | No |
| simple.value.array | <array> [10,20] | No | No |
| simple.value.int | <integer> 10 | No | No |
| simple.value.string | <string> test | No | No |
+--------------------------------------------------------------+-------------------------------------------------------------+--------+-------+
composer require --dev ion-bazan/laravel-container-debug
Thanks to Laravel's Package Auto-Discovery, you don't need to register the ServiceProvider.
If you don't use auto-discovery, add the Service Provider to the providers
array in your config/app.php
:
\IonBazan\Laravel\ContainerDebug\ServiceProvider::class,
For Lumen, register the Service Provider in your bootstrap/app.php
:
$app->register(\IonBazan\Laravel\ContainerDebug\ServiceProvider::class);
TL;DR: php artisan container:debug --help
Usage is pretty straightforward:
- to list all services:
php artisan container:debug
- to check specific service:
php artisan container:debug MyFooService
- to list all tags with tagged services:
php artisan container:debug --tags
- to list all services with tag:
php artisan container:debug --tag=foo
The command does it best to find the service you want by stripping slashes in service names and looking for any occurrences of given name in service names.
For example, to display service.foo
service information, simply use php artisan container:debug foo
. If there are more services with the similar name, a prompt will be shown to choose the one you are looking for.
To get the class name of the service, it must be initialized. To check how much time it took for each service, you may use --profile
option.