久久久久久久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())
主站蜘蛛池模板: 国产欧美精品一区二区 | 国产一区二区视频在线 | www.日韩| 国产一区www | 久久88 | 久久精品国产一区老色匹 | www.成人.com | 精品av天堂毛片久久久借种 | 午夜一区二区三区视频 | av片在线免费看 | 久久99精品久久久久久 | 日韩欧美国产一区二区 | 91免费福利视频 | 狠狠爱免费视频 | 久久久久国产成人精品亚洲午夜 | 亚洲视频区 | 玖玖在线精品 | 成人av观看| 91视频导航 | www.日日干 | 亚洲精品久久久久久久久久久久久 | 国产精品久久a | 国产一区二区在线91 | 国产欧美精品一区二区三区 | 亚洲视频在线观看 | 亚洲三区视频 | 成人亚洲在线 | 九九伊人sl水蜜桃色推荐 | 久久99精品久久久久久 | 欧美精品电影一区 | 雨宫琴音一区二区在线 | 中国美女撒尿txxxxx视频 | 狠狠干天天干 | 久久精品亚洲 | 亚洲国产中文字幕 | 91精品久久久久久久久中文字幕 | 成人影院网站ww555久久精品 | 在线观看精品视频网站 | 黄色精品| 亚洲男人的天堂网站 | 国产亚洲一区二区在线观看 |