久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Laravel 中使用的 Facades 是什么?

What is Facades used in Laravel?(Laravel 中使用的 Facades 是什么?)
本文介紹了Laravel 中使用的 Facades 是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我對 Laravel 提供的 Facades 感到困惑.

Laravel 中的外墻

Facades 提供了一個靜態"的結構.應用程序的服務容器中可用的類的接口.Laravel 附帶了許多門面,可以訪問幾乎所有 Laravel 的功能.Laravel 外觀充當靜態代理"到服務容器中的底層類,提供簡潔、富有表現力的語法的好處,同時比傳統的靜態方法保持更多的可測試性和靈活性.

Facades 在 Laravel 中是如何實現的

容器內的每個服務都有一個唯一的名稱.在 Laravel 應用程序中,要直接從容器訪問服務,我們可以使用 App::make() 方法或 app() 輔助函數.

methodName();

在 Laravel 中,所有服務都有一個外觀類.這些 Facade 類擴展了 Facade 基類,它是 Illuminate/Support 包的一部分.他們唯一需要實現的是 getFacadeAccessor 方法,該方法返回容器內的服務名稱.

I'm confused by the Facades offered by Laravel.

The Laravel documentation states:

Facades provide a "static" interface to classes that are available in the application's service container. Laravel ships with many facades which provide access to almost all of Laravel's features. Laravel facades serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.

Please help me to understand:

  1. Why we really use use IlluminateSupportFacades?
  2. How to create custom Facades ?

解決方案

Props to SitePoint for sharing such informative and helpful knowledge about facades in Laravel.

The facade pattern is a software design pattern that is often used in object-oriented programming.

A facade is a class wrapping a complex library to provide a simpler and more readable interface to it.

Facades in Laravel

Facades provide a "static" interface to classes that are available in the application's service container. Laravel ships with many facades which provide access to almost all of Laravel's features. Laravel facades serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.

How Facades Are implemented in Laravel

Every service inside the container has a unique name. In a Laravel application, to access a service directly from the container, we can use the App::make() method or the app() helper function.

<?php

App::make('some_service')->methodName();

In Laravel, all services have a facade class. These facade classes extend the base Facade class which is part of the Illuminate/Support package. The only thing that they need to implement is the getFacadeAccessor method, which returns the service name inside the container.

這篇關于Laravel 中使用的 Facades 是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數)
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應內容必須是實現 __toString()、“boolean和“boolean的字符串或對象.移動到 psql 后給出) - IT屋-程
Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允許管理員訪問某些根)
Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())
主站蜘蛛池模板: 精品视频一二区 | 羞羞视频在线网站观看 | 亚洲一一在线 | 久久久久国产一区二区三区 | 日韩av一区二区在线 | 国产特级毛片 | 日本国产精品视频 | 天久久| 黄色精品| 一区二区三区国产精品 | 国产欧美精品一区二区色综合朱莉 | 免费黄色大片 | 国产欧美视频一区二区三区 | 香蕉久久久 | 国产 日韩 欧美 制服 另类 | 精品国产一区三区 | 九九热免费在线观看 | 国产精品伦一区二区三级视频 | 天堂在线中文 | 欧美精品综合 | 91一区二区三区 | 在线视频中文字幕 | 国产高清在线精品一区二区三区 | 日韩第一区 | 一本一道久久a久久精品蜜桃 | 日韩视频在线一区二区 | 亚洲一区二区三区免费视频 | 999热精品视频 | 精品婷婷| 国产精品视频一二三区 | 波多野结衣先锋影音 | 亚洲福利在线观看 | 搞av.com| 男女污污动态图 | 国产免费一二三区 | 精品国产18久久久久久二百 | 激情91| 日本爱爱视频 | 色综合久久天天综合网 | 日韩一区中文字幕 | av免费电影在线 |