跳转到内容

外观

facades 为应用程序的核心功能提供了一个"静态"接口,并提供了更灵活、更优雅且易于测试的语法。

Goravel 的所有 facades 都定义在 github.com/goravel/framework/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()
}

Facade 类参考

Facade文档
App容器
Artisan命令行控制台
Auth认证
Cache缓存
Config配置
Crypt加密
Event事件
Gate授权
GrpcGrpc
Hash哈希
Log日志
Mail邮件
OrmORM
Queue队列
RateLimiter速率限制器
Route路由
Seeder种子
Schedule调度
Storage存储
Testing测试
Validation验证

基于 MIT 许可发布