Facades

Introduction

facades provide a "static" interface for the core functionality of the application and provide a more flexible, more elegant, and easy-to-test syntax.

All facades of Goravel are defined under github.com/goravel/framework/facades. We can easily use facades:

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

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

How Facades Work

facades are generally instantiated in the Register or Boot stage of each module ServerProvider.

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

If the facades use other facades, then instantiate them in the Boot phase of the ServerProvider:

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

Facade Class Reference

FacadeDocument
AppContainer
ArtisanCommand Console
AuthAuthentication
CacheCache
ConfigConfiguration
CryptEncryption
EventEvent
GateAuthorization
GrpcGrpc
HashHashing
LogLog
MailMail
OrmORM
QueueQueue
RateLimiterRateLimiter
RouteRoute
SeederSeeder
ScheduleSchedule
StorageStorage
TestingTesting
ValidationValidation