github.com/goravel/framework@v1.13.9/contracts/foundation/container.go (about)

     1  package foundation
     2  
     3  import (
     4  	"github.com/goravel/framework/contracts/auth"
     5  	"github.com/goravel/framework/contracts/auth/access"
     6  	"github.com/goravel/framework/contracts/cache"
     7  	"github.com/goravel/framework/contracts/config"
     8  	"github.com/goravel/framework/contracts/console"
     9  	"github.com/goravel/framework/contracts/crypt"
    10  	"github.com/goravel/framework/contracts/database/orm"
    11  	"github.com/goravel/framework/contracts/database/seeder"
    12  	"github.com/goravel/framework/contracts/event"
    13  	"github.com/goravel/framework/contracts/filesystem"
    14  	"github.com/goravel/framework/contracts/grpc"
    15  	"github.com/goravel/framework/contracts/hash"
    16  	"github.com/goravel/framework/contracts/http"
    17  	"github.com/goravel/framework/contracts/log"
    18  	"github.com/goravel/framework/contracts/mail"
    19  	"github.com/goravel/framework/contracts/queue"
    20  	"github.com/goravel/framework/contracts/route"
    21  	"github.com/goravel/framework/contracts/schedule"
    22  	"github.com/goravel/framework/contracts/testing"
    23  	"github.com/goravel/framework/contracts/validation"
    24  )
    25  
    26  type Container interface {
    27  	// Bind registers a binding with the container.
    28  	Bind(key any, callback func(app Application) (any, error))
    29  	// BindWith registers a binding with the container.
    30  	BindWith(key any, callback func(app Application, parameters map[string]any) (any, error))
    31  	// Instance registers an existing instance as shared in the container.
    32  	Instance(key, instance any)
    33  	// Make resolves the given type from the container.
    34  	Make(key any) (any, error)
    35  	// MakeArtisan resolves the artisan console instance.
    36  	MakeArtisan() console.Artisan
    37  	// MakeAuth resolves the auth instance.
    38  	MakeAuth() auth.Auth
    39  	// MakeCache resolves the cache instance.
    40  	MakeCache() cache.Cache
    41  	// MakeConfig resolves the config instance.
    42  	MakeConfig() config.Config
    43  	// MakeCrypt resolves the crypt instance.
    44  	MakeCrypt() crypt.Crypt
    45  	// MakeEvent resolves the event instance.
    46  	MakeEvent() event.Instance
    47  	// MakeGate resolves the gate instance.
    48  	MakeGate() access.Gate
    49  	// MakeGrpc resolves the grpc instance.
    50  	MakeGrpc() grpc.Grpc
    51  	// MakeHash resolves the hash instance.
    52  	MakeHash() hash.Hash
    53  	// MakeLog resolves the log instance.
    54  	MakeLog() log.Log
    55  	// MakeMail resolves the mail instance.
    56  	MakeMail() mail.Mail
    57  	// MakeOrm resolves the orm instance.
    58  	MakeOrm() orm.Orm
    59  	// MakeQueue resolves the queue instance.
    60  	MakeQueue() queue.Queue
    61  	// MakeRateLimiter resolves the rate limiter instance.
    62  	MakeRateLimiter() http.RateLimiter
    63  	// MakeRoute resolves the route instance.
    64  	MakeRoute() route.Route
    65  	// MakeSchedule resolves the schedule instance.
    66  	MakeSchedule() schedule.Schedule
    67  	// MakeStorage resolves the storage instance.
    68  	MakeStorage() filesystem.Storage
    69  	// MakeTesting resolves the testing instance.
    70  	MakeTesting() testing.Testing
    71  	// MakeValidation resolves the validation instance.
    72  	MakeValidation() validation.Validation
    73  	// MakeView resolves the view instance.
    74  	MakeView() http.View
    75  	// MakeSeeder resolves the seeder instance.
    76  	MakeSeeder() seeder.Facade
    77  	// MakeWith resolves the given type with the given parameters from the container.
    78  	MakeWith(key any, parameters map[string]any) (any, error)
    79  	// Singleton registers a shared binding in the container.
    80  	Singleton(key any, callback func(app Application) (any, error))
    81  }