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
Facade | Document |
---|---|
App | Container |
Artisan | Command Console |
Auth | Authentication |
Cache | Cache |
Config | Configuration |
Crypt | Encryption |
Event | Event |
Gate | Authorization |
Grpc | Grpc |
Hash | Hashing |
Log | Log |
Orm | ORM |
Queue | Queue |
RateLimiter | RateLimiter |
Route | Route |
Seeder | Seeder |
Schedule | Schedule |
Storage | Storage |
Testing | Testing |
Validation | Validation |