ServiceContainer
extends Kernel
in package
Table of Contents
Properties
- $basedir : string
- $counter : int
- $isAppBooted : bool
- $providers : array<string|int, mixed>
- $services : array<string|int, mixed>
- $instances : mixed
Methods
- __get() : object|callable
- Retrieves magically the service or callable.
- __wakeup() : mixed
- Singletons should not be restorable from strings.
- bootApplication() : ServiceContainer
- Boots main App.
- bootProviders() : ServiceContainer
- Boots all already registered service providers.
- bootstrap() : ServiceContainer
- Bootstraps application.
- get() : object|callable
- Gets the service or definition if it's already registered.
- getInstance() : mixed
- Returns the singleton instance.
- getProviders() : array<string|int, mixed>
- Gets the current registered providers from /config/providers.php.
- getServices() : array<string|int, mixed>
- Returns the array of registered services.
- register() : void
- Registers a service or a definition.
- registerProviders() : ServiceContainer
- Registers service providers.
- run() : void
- Runs the application.
- setBaseDir() : ServiceContainer
- Sets the APP basedir
- singleton() : void
- Bootstraps singleton services.
- __clone() : mixed
- Singletons should not be cloneable.
- __construct() : mixed
- Constructor has to be protected to avoid instantiation from outside.
- isProvider() : bool
- Validates if a service provider.
Properties
$basedir
public
string
$basedir
= ''
$counter
public
static int
$counter
= 0
Counter self instances
$isAppBooted
public
bool
$isAppBooted
= false
$providers
protected
array<string|int, mixed>
$providers
= []
$services
protected
array<string|int, mixed>
$services
= []
$instances
private
static mixed
$instances
= []
can be an object from View, Response or any other class that uses singleton pattern.
Methods
__get()
Retrieves magically the service or callable.
public
__get(string $name) : object|callable
Parameters
- $name : string
Return values
object|callable__wakeup()
Singletons should not be restorable from strings.
public
__wakeup() : mixed
bootApplication()
Boots main App.
public
bootApplication() : ServiceContainer
Add here any setup that is required to take place before anything else.
Return values
ServiceContainerbootProviders()
Boots all already registered service providers.
public
bootProviders() : ServiceContainer
Return values
ServiceContainerbootstrap()
Bootstraps application.
public
bootstrap() : ServiceContainer
Return values
ServiceContainerget()
Gets the service or definition if it's already registered.
public
get(string $name) : object|callable
Parameters
- $name : string
Return values
object|callablegetInstance()
Returns the singleton instance.
public
static getInstance() : mixed
getProviders()
Gets the current registered providers from /config/providers.php.
public
getProviders() : array<string|int, mixed>
Return values
array<string|int, mixed>getServices()
Returns the array of registered services.
public
getServices() : array<string|int, mixed>
Return values
array<string|int, mixed>register()
Registers a service or a definition.
public
register(string $name, string|callable $service) : void
Parameters
- $name : string
- $service : string|callable
registerProviders()
Registers service providers.
public
registerProviders() : ServiceContainer
Return values
ServiceContainerrun()
Runs the application.
public
run() : void
setBaseDir()
Sets the APP basedir
public
setBaseDir(string $dir) : ServiceContainer
Parameters
- $dir : string
Return values
ServiceContainersingleton()
Bootstraps singleton services.
public
singleton(string $name, string|callable $service) : void
Parameters
- $name : string
- $service : string|callable
__clone()
Singletons should not be cloneable.
protected
__clone() : mixed
__construct()
Constructor has to be protected to avoid instantiation from outside.
protected
__construct() : mixed
isProvider()
Validates if a service provider.
private
isProvider(string $providerWithNamespace) : bool
Parameters
- $providerWithNamespace : string