Home>Article>PHP Framework> Laravel facade contracts (facades) and contracts (contracts)
The following tutorial column ofLaravel Frameworkwill introduce laravel facades and contracts to you. I hope it will be helpful to friends in need!
1. How to define Laravel’s facade?
All facades are defined in the Illuminate\Support\Facades namespace.
2. Understanding of facades
Facades (pronounced: /fəˈsäd/) provide a "static" interface for classes available in the application'sservice container
. You don't have touse
a long list of namespaces or instantiate the object to access the object's specific methods.
Same facades need to be registered and activated.
laravel I like it very much, register (register) start (bootstrap)
The startup guide of Facade is inIlluminate\Foundation\Bootstrap\RegisterFacades
Registered.
/** * Prepend the load method to the auto-loader stack. * * @return void */ protected function register() { if (! $this->registered) { spl_autoload_register([$this, 'load'], true, true); $this->registered = true; } }
For specific implementation logic, you can view the original text: Laravel Facade loading process and principle
3. Explain the concept of contract in Laravel
They are a collection of interfaces of the Laravel framework. These contracts provide core services. Contracts in Laravel include corresponding framework implementations.
Thinking
The above is the detailed content of Laravel facade contracts (facades) and contracts (contracts). For more information, please follow other related articles on the PHP Chinese website!