smcrow/binding-utilities

This package is abandoned and no longer maintained. The author suggests using the smcrow/laravel-container-info package instead.

Artisan commands for getting information about the IoC container.

1.2.2 2017-11-05 15:19 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:08:54 UTC


README

Latest Stable Version Latest Unstable Version Total Downloads Build Status

This is a suite of custom commands for Artisan that gives information about the IoC container. The following commands are added:

Working with Bindings

  • binding:list - Lists the registered bindings by showing the abstract (interface) and concrete class that will be injected.
    • --include-illuminate - Indicates that Illuminate classes should be included. They are not included by default.
  • binding:usage - Lists the registered bindings and which files they are referenced in. By default will exclude node_modules and vendor.
    • --include-illuminate - Indicates that Illuminate classes should be included. They are not included by default.
    • --include-vendor - Indicates that the vendor directory should be included. It is not included by default.
    • --exclude= - A comma separated string that indicates which directories to exclude.
    • --sort - Indicates that the information should be sorted.

Working with Service Providers

  • provider:list - Lists the registered service providers.
    • --include-illuminate - Indicates that Illuminate classes should be included. They are not included by default.
    • --sort - Indicates that the information should be sorted.

Usage

Install Through Composer

composer require smcrow/laravel-container-info --dev

Register the Command

Laravel 5.5

Laravel 5.5 allows for the auto-discovery of service providers. The ContainerInformationProvider will automatically be discovered.

Pre Laravel 5.5

You'll need to register the command in order for it to be usable. Modify the register method of AppServiceProvider This will add the provider for the local environment:

public function register()
{
    if ($this->app->environment() === 'local') {
        $this->app->register(ContainerInformationProvider::class);
    }
}

Example Usage

php artisan binding:list

Here's sample output from the binding:list command from my LeaseTracker application.

+-----------------------------------------------------------------+--------------------------------------------------------------+
| Abstract                                                        | Concrete                                                     |
+-----------------------------------------------------------------+--------------------------------------------------------------+
| Illuminate\Contracts\Http\Kernel                                | LeaseTracker\Http\Kernel                                     |
| Illuminate\Contracts\Console\Kernel                             | LeaseTracker\Console\Kernel                                  |
| Illuminate\Contracts\Debug\ExceptionHandler                     | LeaseTracker\Exceptions\Handler                              |
| Illuminate\Session\Middleware\StartSession                      | Illuminate\Session\Middleware\StartSession                   |
| LeaseTracker\Services\Vehicle\VehicleServiceInterface           | LeaseTracker\Services\Vehicle\VehicleService                 |
| LeaseTracker\Services\Mileage\MileageServiceInterface           | LeaseTracker\Services\Mileage\MileageService                 |
| LeaseTracker\Services\Calculation\CalculationServiceInterface   | LeaseTracker\Services\Calculation\CalculationService         |
| LeaseTracker\Services\VehicleImage\VehicleImageServiceInterface | LeaseTracker\Services\VehicleImage\GoogleVehicleImageService |
| LeaseTracker\Repositories\VehicleRepositoryInterface            | LeaseTracker\Repositories\VehicleRepository                  |
| LeaseTracker\Repositories\MileEntryRepositoryInterface          | LeaseTracker\Repositories\MileEntryRepository                |
| Illuminate\Console\Scheduling\ScheduleFinishCommand             | Illuminate\Console\Scheduling\ScheduleFinishCommand          |
| Illuminate\Console\Scheduling\ScheduleRunCommand                | Illuminate\Console\Scheduling\ScheduleRunCommand             |
| Illuminate\Contracts\Pipeline\Hub                               | Illuminate\Pipeline\Hub                                      |
+-----------------------------------------------------------------+--------------------------------------------------------------+
php artisan provider:list

Here's sample output from a dummy application:

+-----------------------------------------------------------------------------+----------+----------------+
| Providers                                                                   | Deferred | Provides       |
+-----------------------------------------------------------------------------+----------+----------------+
| Fideloper\Proxy\TrustedProxyServiceProvider                                 |          |                |
| Smcrow\ContainerInformation\BindingInformation\BindingInformationProvider   |          |                |
| Smcrow\ContainerInformation\ProviderInformation\ProviderInformationProvider |          |                |
| Smcrow\ContainerInformation\ContainerInformationProvider                    |          |                |
| App\Providers\AppServiceProvider                                            |          |                |
| App\Providers\AuthServiceProvider                                           |          |                |
| App\Providers\EventServiceProvider                                          |          |                |
| App\Providers\RouteServiceProvider                                          |          |                |
| Laravel\Tinker\TinkerServiceProvider                                        | true     | command.tinker |
+-----------------------------------------------------------------------------+----------+----------------+

Feedback and Contributions

Please feel free to offer suggestions by submitting an Issue. Alternatively, submit a pull request with any features you wish to add. This is a work-in-progress, and I would welcome any and all feedback.