In laravel, provider is the guidance center of an application, also called a service provider, which is the core of the laravel program; including applications, all Laravel core services are through the service provider When activated, it can provide identity information services, mailing address services, etc.
The operating environment of this article: Windows 10 system, Laravel version 5.4, Dell G3 computer.
Service Providers (service providers) are the core of Laravel's "bootstrap" process.
Service providers are the bootstrapping center for all Laravel applications. Your application, as well as the core Laravel services bootstrapped through the server, are bootstrapped through service providers.
Guidance can generally be understood as registration, such as registering service container bindings, event listeners, middleware, and even routing. Service providers are central to configuring applications.
Laravel's service provider feels like the implementation of the singleton mode (singleton mode, that is, there is only one instance of this class in the entire session)
We must be clear about what we are using Know certain concepts, such as a user service provider, will register user services or other services (such as identity information services, mailing address services, etc.).
User Service Provider: Identity Information Service, Mailing Address Service
This "bootstrap" process can be understood as what the system does during the period from when the computer presses the power-on button to fully entering the desktop. thing.
Provider is the core of the laravel program, including your own application and all Laravel core services, which are started through the service provider. Generally speaking, we mean registering things, including registering service container bindings, event listeners, middleware, and even routes. Service providers are the central place for setting up your application.
Extended knowledge:
How to customize a laravel provider can be achieved in the following way.
1. In the first step, enter the laravel directory and generate the provider file through the command line.
php artisan make:provider GuzzleClientProvider
2. In the second step, you will see the produced GuzzleClientProvider.php file
3. In the third step, you can register content for this provider
4. In the fourth step, you can write the class for provider registration
5. Finally, register this provider in config/app.php
[Related recommendations: laravel video tutorial]
The above is the detailed content of What is provider in laravel. For more information, please follow other related articles on the PHP Chinese website!