Home  >  Article  >  PHP Framework  >  What is provider in laravel

What is provider in laravel

WBOY
WBOYOriginal
2022-06-02 17:38:283680browse

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.

What is provider in laravel

The operating environment of this article: Windows 10 system, Laravel version 5.4, Dell G3 computer.

What is provider in laravel

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

What is provider in laravel

3. In the third step, you can register content for this provider

What is provider in laravel

4. In the fourth step, you can write the class for provider registration

What is provider in laravel

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn