Download the PHP package gidato/laravel-container-extensions without Composer
On this page you can find all versions of the php package gidato/laravel-container-extensions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gidato/laravel-container-extensions
More information about gidato/laravel-container-extensions
Files in gidato/laravel-container-extensions
Package laravel-container-extensions
Short Description Extensions for Laravels Container and App
License MIT
Informations about the package laravel-container-extensions
Gidato / Laravel-Container-Extensions
You then need to find the following line in \bootstrap\app.php
And change it as follows:
Nested Containers
A separate container can be created and used within a container, effectively namespacing the bound elements.
This allows specific parts of the application to be directly associated with a specific container.
To access sub containers, you can use app()->container("name-of-container")
, and then bind things to this level.
Directly bound classes can then be retrieved (if you want them all), using $container->getAllBound()
. This will give only specifically bound classes/objects, and will not deliver any that could be dynamically created.
If you want to exclude other nested containers from this call, use $container->getAllBound($recursive = true)
Binding using Factory Creation
Instead of creating a closure in the Provider, this allows the creation to be done within a factory class, which can then live with the class, making it more accessible.
The factory must implement Gidato\Container\Contract\FactoryContract
which requires that the class be invokable. The method should be defined to match the following:
And then, in the provider, class can be bound using:
License
This software is open-sourced software licensed under the MIT license.