Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application interface {
// About add information to the application's about command.
About(section string, items []AboutItem)
// Boot register and bootstrap configured service providers.
// It can be deprecated in the future given the With* functions are implemented.
Boot()
// Build creates a new application instance after configuring.
Build() Application
// Commands register the given commands with the console application.
Commands([]console.Command)
// Context gets the application context.
Context() context.Context
// GetJson get the JSON implementation.
// DEPRECATED, use Json instead.
GetJson() Json
// IsLocale get the current application locale.
IsLocale(ctx context.Context, locale string) bool
// Json gets the JSON implementation.
Json() Json
// Publishes register the given paths to be published by the "vendor:publish" command.
Publishes(packageName string, paths map[string]string, groups ...string)
// Refresh reboots facades after changing config, if you want to restart the runners as well, please use the Restart method.
Refresh()
// Restart restarts the application.
Restart() error
// SetBuilder sets the application builder.
SetBuilder(builder ApplicationBuilder) Application
// SetJson set the JSON implementation.
SetJson(json Json)
// SetLocale set the current application locale.
SetLocale(ctx context.Context, locale string) context.Context
// Shutdown the application and all its runners.
Shutdown() error
// Start starts modules.
Start()
// Version gets the version number of the application.
Version() string
// BasePath get the base path of the Goravel installation.
BasePath(path ...string) string
// BootstrapPath gets the path to the bootstrap directory.
BootstrapPath(path ...string) string
// ConfigPath get the path to the configuration files.
ConfigPath(path ...string) string
// CurrentLocale get the current application locale.
CurrentLocale(ctx context.Context) string
// ModelPath get the path to the models directory.
ModelPath(path ...string) string
// DatabasePath get the path to the database directory.
DatabasePath(path ...string) string
// ExecutablePath get the path to the executable of the running Goravel application.
ExecutablePath(path ...string) string
// FacadesPath get the path to the facade files.
FacadesPath(path ...string) string
// LangPath get the path to the language files.
LangPath(path ...string) string
// Path gets the path respective to "app" directory.
Path(path ...string) string
// PublicPath get the path to the public directory.
PublicPath(path ...string) string
// ResourcePath get the path to the resources directory.
ResourcePath(path ...string) string
// StoragePath get the path to the storage directory.
StoragePath(path ...string) string
// Bind registers a binding with the container.
Bind(key any, callback func(app Application) (any, error))
// Bindings returns all bindings registered in the container.
Bindings() []any
// BindWith registers a binding with the container.
BindWith(key any, callback func(app Application, parameters map[string]any) (any, error))
// Fresh modules after changing config, will fresh all bindings except for config if no bindings provided.
// Notice, this method only freshs the facade, if another facade injects the facade previously, the another
// facades should be fresh simulaneously.
Fresh(bindings ...any)
// Instance registers an existing instance as shared in the container.
Instance(key, instance any)
// Make resolves the given type from the container.
Make(key any) (any, error)
// MakeArtisan resolves the artisan console instance.
MakeArtisan() console.Artisan
// MakeAuth resolves the auth instance.
MakeAuth(ctx ...http.Context) auth.Auth
// MakeCache resolves the cache instance.
MakeCache() cache.Cache
// MakeConfig resolves the config instance.
MakeConfig() config.Config
// MakeCrypt resolves the crypt instance.
MakeCrypt() crypt.Crypt
// MakeDB resolves the db instance.
MakeDB() db.DB
// MakeEvent resolves the event instance.
MakeEvent() event.Instance
// MakeGate resolves the gate instance.
MakeGate() access.Gate
// MakeGrpc resolves the grpc instance.
MakeGrpc() grpc.Grpc
// MakeHash resolves the hash instance.
MakeHash() hash.Hash
// MakeHttp resolves the http instance.
MakeHttp() client.Factory
// MakeLang resolves the lang instance.
MakeLang(ctx context.Context) translation.Translator
// MakeLog resolves the log instance.
MakeLog() log.Log
// MakeMail resolves the mail instance.
MakeMail() mail.Mail
// MakeOrm resolves the orm instance.
MakeOrm() orm.Orm
// MakeProcess resolves the process instance.
MakeProcess() process.Process
// MakeQueue resolves the queue instance.
MakeQueue() queue.Queue
// MakeRateLimiter resolves the rate limiter instance.
MakeRateLimiter() http.RateLimiter
// MakeRoute resolves the route instance.
MakeRoute() route.Route
// MakeSchedule resolves the schedule instance.
MakeSchedule() schedule.Schedule
// MakeSchema resolves the schema instance.
MakeSchema() schema.Schema
// MakeSession resolves the session instance.
MakeSession() session.Manager
// MakeStorage resolves the storage instance.
MakeStorage() filesystem.Storage
// MakeTelemetry resolves the telemetry instance.
// MakeTelemetry() telemetry.Telemetry
// MakeTesting resolves the testing instance.
MakeTesting() testing.Testing
// MakeValidation resolves the validation instance.
MakeValidation() validation.Validation
// MakeView resolves the view instance.
MakeView() view.View
// MakeSeeder resolves the seeder instance.
MakeSeeder() seeder.Facade
// MakeWith resolves the given type with the given parameters from the container.
MakeWith(key any, parameters map[string]any) (any, error)
// Singleton registers a shared binding in the container.
Singleton(key any, callback func(app Application) (any, error))
}
type ApplicationBuilder ¶ added in v1.17.0
type ApplicationBuilder interface {
// Create a new application instance after configuring.
Create() Application
// WithCallback sets a callback function to be called during application creation.
WithCallback(func()) ApplicationBuilder
// WithCommands sets the application's commands.
WithCommands(func() []console.Command) ApplicationBuilder
// WithConfig sets a callback function to configure the application.
WithConfig(func()) ApplicationBuilder
// WithEvents sets event listeners for the application.
WithEvents(func() map[event.Event][]event.Listener) ApplicationBuilder
// WithFilters sets the application's validation filters.
WithFilters(func() []validation.Filter) ApplicationBuilder
// WithGrpcClientInterceptors sets the grouped gRPC client interceptors.
WithGrpcClientInterceptors(func() map[string][]grpc.UnaryClientInterceptor) ApplicationBuilder
// WithGrpcClientStatsHandlers sets the grouped gRPC client stats handlers.
WithGrpcClientStatsHandlers(func() map[string][]stats.Handler) ApplicationBuilder
// WithGrpcServerInterceptors sets the list of gRPC server interceptors.
WithGrpcServerInterceptors(func() []grpc.UnaryServerInterceptor) ApplicationBuilder
// WithGrpcServerStatsHandlers sets the list of gRPC server stats handlers.
WithGrpcServerStatsHandlers(func() []stats.Handler) ApplicationBuilder
// WithJobs registers the application's jobs.
WithJobs(func() []queue.Job) ApplicationBuilder
// WithMiddleware registers the http's middleware.
WithMiddleware(func(handler configuration.Middleware)) ApplicationBuilder
// WithMigrations registers the database migrations.
WithMigrations(func() []schema.Migration) ApplicationBuilder
// WithPaths sets custom paths for the application.
WithPaths(func(paths configuration.Paths)) ApplicationBuilder
// WithProviders registers and boots custom service providers.
WithProviders(func() []ServiceProvider) ApplicationBuilder
// WithRouting registers the application's routes.
WithRouting(func()) ApplicationBuilder
// WithRules registers the custom validation rules.
WithRules(func() []validation.Rule) ApplicationBuilder
// WithRunners registers the application's runners.
WithRunners(func() []Runner) ApplicationBuilder
// WithSchedule sets scheduled events for the application.
WithSchedule(func() []schedule.Event) ApplicationBuilder
// WithSeeders registers the database seeders.
WithSeeders(func() []seeder.Seeder) ApplicationBuilder
}
type Json ¶ added in v1.14.0
type Json interface {
// Marshal serializes the given value to a JSON-encoded byte slice.
Marshal(any) ([]byte, error)
// Unmarshal deserializes the given JSON-encoded byte slice into the provided value.
Unmarshal([]byte, any) error
// MarshalString serializes the given value to a JSON-encoded string.
MarshalString(any) (string, error)
// UnmarshalString deserializes the given JSON-encoded string into the provided value.
UnmarshalString(string, any) error
}
type ProviderRepository ¶ added in v1.17.0
type ProviderRepository interface {
// Add appends new providers to the repository.
// It skips any providers that have already been added.
Add(providers []ServiceProvider)
// Boot boots all registered service providers in dependency order.
Boot(app Application)
// GetBooted returns a slice of all providers that have been booted.
GetBooted() []ServiceProvider
// LoadFromConfig lazy-loads providers from the "app.providers" config.
LoadFromConfig(config config.Config) []ServiceProvider
// Register sorts and registers all configured providers in dependency order.
Register(app Application) []ServiceProvider
// Reset clears all configured providers and cached state.
Reset()
}
type ServiceProvider ¶
type ServiceProvider interface {
// Register any application services.
Register(app Application)
// Boot any application services after register.
Boot(app Application)
}
type ServiceProviderWithRelations ¶ added in v1.15.12
type ServiceProviderWithRelations interface {
ServiceProvider
// Relationship returns the service provider's relationship.
Relationship() binding.Relationship
}
type ServiceProviderWithRunners ¶ added in v1.17.0
type ServiceProviderWithRunners interface {
ServiceProvider
// Runners returns the service provider's runners.
Runners(app Application) []Runner
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.