Providing The Core 核心也是服务提供者的模式
By now you have probably noticed that your application already has many service providers registered in the ``app`` configuration file. Each of these service providers bootstraps a part of the framework core. For example, the ``MigrationServiceProvider`` bootstraps the various classes that run migrations, as well as the migration Artisan commands. The ``EventServiceProvider`` bootstraps and registers the event dispatcher class. Some of these providers are larger than others, but they each bootstrap a piece of the core.
> Meet Your Providers
>
> One of the best way to improve your understanding of the Laravel core is to read the source for the core service providers. If you are familiar with the function of service providers and what each core service provider registers, you will have an incredibly better understanding of how Laravel works under the hood.
>
Most of the core providers are deferred, meaning they do not load on every request; however, some, such as the ``FilesystemServiceProvider`` and ``ExceptionServiceProvider`` load on every request to your application since they bootstrap very foundational piece of the framework. One might say that the core service providers and the application container are Laravel. They are what ties all of the various pieces of the framework together into a single, cohesive unit. These providers are the building blocks of the framework.
As mentioned previously, if you wish to gain a deeper understanding of how the framework works, read the source code of the core service providers that ship with Laravel. By reading through these providers, you will gain a solid understanding of how the framework is put together, as well as what each provider offers to your application. Furthermore, you will be better prepared to contribute to Laravel itself!
- Dependency Injection
- The Problem
- Build A Contract
- Take It further
- Too Much Java?
- The IoC Container
- Basic Binding
- Reflective Resolution
- Interface As Contract
- Strong Typing & Water Fowl
- A Contract Example
- Interface & Team Development
- Service Provider
- As Bootstrapper
- As Organizer
- Booting Providers
- Providing The Core
- Application Structure
- MVC Is Killing You
- Bye, Bye Models
- It's All About The Layers
- Where To Put "Stuff"
- Applied Architecture: Decoupling Handles
- Decoupling Handlers
- Other Handlers
- Extending The Framework
- Manager & Factories
- Cache
- Session
- Authentication
- IoC Based Extension
- Request Extension
- Single Responsibility Principle
- Open Closed Principle