Example Analysis of Laravel 5.5Core Architecture
This article shares with you the content of a sample analysis of the core architecture of Laravel 5.5. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Dependency injection
Method is passed in the component name, and the framework is automatically instantiated, which can be used directly within the method
For example, the most commonly used requert object
2. Service container
In fact, the core of Laravel is an IoC container. The core of Laravel itself is very lightweight, and there are no magical and substantive application functions. The various functional modules used by many people, such as Route (routing), Eloquent ORM (database ORM component), Request (request), Response (response), and so on, are actually provided by core-independent class modules. From registration to instantiation, these classes are finally used by you, in fact, the service container of Laravel is responsible for them.
Service providers are mainly divided into two parts, register (registration) and boot (boot, initialization)
3. Service provider
For a class to be extracted by a container, it must first be registered with the container. Since Laravel calls this container a service container, if we need a service, we have to register and bind the service to the container, so the thing that provides the service and binds the service to the container is the service provider (Service Provider).
4. Add your own class to the IOC container
4.1. create a new validate class
4.2. Create a new validateProvider
Bind the validate class to Provider