1. Introduction
The Laravel service container is a powerful tool for managing class dependencies and performing dependency injection, which refers to dependency classes injected into code through constructors or "setter" methods.
2, the difference with the Laravel
The lumen and laravel frameworks use the same service container, so for complete documentation on the service container, refer to the Complete Laravel service container documentation.
Accessing Containers
Laravel\lumen\application instances are inherited from Illuminate\container\container and are therefore used as service containers for the application.
Typically, you can register bindings to a container in a service provider, and you can use BIND, singleton, instance, and other methods provided by the container to implement the binding operation.
parsing an instance
To parse an object from a container, you can inject the object with a type hint in a class that the container has automatically resolved, such as a routing closure, controller constructor, controller method, middleware, event listener, or queue task, or you can use the app function to parse directly:
$instance = App (Something::class);