Home > PHP Framework > Laravel > body text

Laravel facade contracts (facades) and contracts (contracts)

藏色散人
Release: 2020-12-18 08:56:53
forward
2671 people have browsed it

The following tutorial column of Laravel Framework will 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

What are facades?

Facades (pronounced: /fəˈsäd/) provide a "static" interface for classes available in the application's service container. You don't have to use a long list of namespaces or instantiate the object to access the object's specific methods.

facades How to register?

Same facades need to be registered and activated.

laravel I like it very much, register (register) start (bootstrap)

The startup guide of Facade is in Illuminate\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;
        }
    }
Copy after login

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

  1. How to read facades Contracts?
  2. How are facades registered and loaded?
  3. What operations do facades facilitate for us?

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!

Related labels:
source:learnku.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!