跳轉到內容

外觀

概述

facades 為應用的核心功能提供一個「靜態」接口,能夠提供更加靈活、更加優雅、易於測試的語法。

Goravel 所有的 facades 都定義在 github.com/goravel/framework/facades 下。 我們可以很輕鬆的使用 facades: 我們可以輕鬆使用 facades

go
import "github.com/goravel/framework/facades"

facades.Route().Run(facades.Config().GetString("app.host"))

外觀的工作原理

facades 一般會在各模組 ServerProviderRegisterBoot 階段進行實例化。

go
func (config *ServiceProvider) Register() {
  app := Application{}
  facades.Config = app.Init()
}

如果該 facades 使用了其他 facades,那麼就在 ServerProviderBoot 階段進行實例化:

go
func (database *ServiceProvider) Boot() {
  app := Application{}
  facades.DB = app.Init()
}

外觀類參考

外觀使用文檔
應用程序容器
藝術家命令行工具
身份驗證用戶認證
快取快取系統
配置配置信息
加密加密解密
事件事件系統
用戶授權
GrpcGrpc
雜湊哈希
日誌日誌
郵件郵件
OrmORM
隊列隊列
速率限制器速率限制器
Route路由
Seeder數據填充
排程任務調度
儲存文件系統
集成測試測試
驗證表單驗證

基於 MIT 许可發佈