Skip to content

Phalcon Container

Updated View as Markdown

Container\Container

ClassSource on GitHub

Uses Closure · Phalcon\Container\Definition\Processor\ClosureProcessor · Phalcon\Container\Definition\Processor\ObjectProcessor · Phalcon\Container\Definition\Processor\Processor · Phalcon\Container\Definition\Processor\StringProcessor · Phalcon\Container\Definition\ServiceDefinition · Phalcon\Container\Definition\ServiceLifetime · Phalcon\Container\Exceptions\CannotExtendResolved · Phalcon\Container\Exceptions\CircularAliasFound · Phalcon\Container\Exceptions\InstanceNotFound · Phalcon\Container\Exceptions\NoProcessorFound · Phalcon\Container\Exceptions\ParameterNotFound · Phalcon\Container\Exceptions\ServiceNotFound · Phalcon\Container\Exceptions\ServiceNotRegistered · Phalcon\Container\Resolver\Lazy\Lazy · Phalcon\Container\Resolver\Resolver · Phalcon\Contracts\Container\Service\Collection · Phalcon\Di\InjectionAwareInterface · ReflectionException

Method Summary

public__construct()publicServiceDefinitionbind(string$interfaceName,string$concrete)Bind an interface to a concrete classpublicClosurecallableGet( string$name )Resolve to a closure on a get()publicClosurecallableNew( string$name )Resolve to a closure on a new()publicvoidextend(string$name,callable$callableObject)Extends the definitionpublicmixedget( string$name )Resolve and return an element registerd in the containerpublicstringgetAlias( string$name )Return an aliaspublicarraygetByTag( string$tag )Return services by tagpublicServiceDefinitiongetDefinition( string$name )Return the service definitionpublicobjectgetInstance( string$name )Return a stored instancepublicmixedgetParameter( string$name )Return a parameterpublicResolvergetResolver()Return the resolverpublicobjectgetService( string$serviceName )Resolve an return a servicepublicboolhas( string$name )Does the container have a particular servicepublicboolhasAlias( string$name )Does the service have an aliaspublicboolhasDefinition( string$name )Does the service have a definitionpublicboolhasInstance( string$name )Does the service have an instancepublicboolhasParameter( string$name )Does the service have a parameterpublicboolhasService( string$serviceName )Does the container have a particular servicepublicboolisAutowireEnabled()Is AutoWiring enabledpublicmixednew( string$name )Resolve and return a new servicepublicServiceDefinitionnewDefinition( string$name )Return a new service definitionpublicServiceDefinitionset(string$name,mixed$definition)Set a servicepublicstaticsetAlias(string$name,string$alias)Set an aliaspublicstaticsetAutowire( bool$enabled )Set AutoWirepublicstaticsetDefinition(string$name,ServiceDefinition$definition)Set a definitionpublicstaticsetInstance(string$name,object$instance,string$lifetime)Set an instancepublicstaticsetParameter(string$name,mixed$value)Set a parameterpublicvoidsetTag(string$tag,string$serviceName)Register a tag with a servicepublicvoidunsetAlias( string$name )Remove an aliaspublicvoidunsetDefinition( string$name )Remove a definitionpublicvoidunsetInstance( string$name )Remove an instancepublicvoidunsetInstances( string$lifetime )Remove instances based on lifetimepublicvoidunsetParameter( string$name )Remove a parameter

Properties

protectedarray<string, string>$aliases = []
protectedbool$autowire = true
protectedarray<string, string>$instanceLifetimes = []
protectedarray<string, object>$instances = []
protectedarray<string, mixed>$parameters = []
protectedarray<string, Processor>$processors = []
protectedResolver$resolver
protectedarray<string, ServiceDefinition>$services = []
protectedarray<string, list<string>>$tags = []

Methods

Public · 34

__construct()

public function __construct();

bind()

public function bind(
    string $interfaceName,
    string $concrete
): ServiceDefinition;

Bind an interface to a concrete class

callableGet()

public function callableGet( string $name ): Closure;

Resolve to a closure on a get()

callableNew()

public function callableNew( string $name ): Closure;

Resolve to a closure on a new()

extend()

public function extend(
    string $name,
    callable $callableObject
): void;

Extends the definition

get()

public function get( string $name ): mixed;

Resolve and return an element registerd in the container

getAlias()

public function getAlias( string $name ): string;

Return an alias

getByTag()

public function getByTag( string $tag ): array;

Return services by tag

getDefinition()

public function getDefinition( string $name ): ServiceDefinition;

Return the service definition

getInstance()

public function getInstance( string $name ): object;

Return a stored instance

getParameter()

public function getParameter( string $name ): mixed;

Return a parameter

getResolver()

public function getResolver(): Resolver;

Return the resolver

getService()

public function getService( string $serviceName ): object;

Resolve an return a service

has()

public function has( string $name ): bool;

Does the container have a particular service

hasAlias()

public function hasAlias( string $name ): bool;

Does the service have an alias

hasDefinition()

public function hasDefinition( string $name ): bool;

Does the service have a definition

hasInstance()

public function hasInstance( string $name ): bool;

Does the service have an instance

hasParameter()

public function hasParameter( string $name ): bool;

Does the service have a parameter

hasService()

public function hasService( string $serviceName ): bool;

Does the container have a particular service

isAutowireEnabled()

public function isAutowireEnabled(): bool;

Is AutoWiring enabled

new()

public function new( string $name ): mixed;

Resolve and return a new service

newDefinition()

public function newDefinition( string $name ): ServiceDefinition;

Return a new service definition

set()

public function set(
    string $name,
    mixed $definition
): ServiceDefinition;

Set a service

setAlias()

public function setAlias(
    string $name,
    string $alias
): static;

Set an alias

setAutowire()

public function setAutowire( bool $enabled ): static;

Set AutoWire

setDefinition()

public function setDefinition(
    string $name,
    ServiceDefinition $definition
): static;

Set a definition

setInstance()

public function setInstance(
    string $name,
    object $instance,
    string $lifetime
): static;

Set an instance

setParameter()

public function setParameter(
    string $name,
    mixed $value
): static;

Set a parameter

setTag()

public function setTag(
    string $tag,
    string $serviceName
): void;

Register a tag with a service

unsetAlias()

public function unsetAlias( string $name ): void;

Remove an alias

unsetDefinition()

public function unsetDefinition( string $name ): void;

Remove a definition

unsetInstance()

public function unsetInstance( string $name ): void;

Remove an instance

unsetInstances()

public function unsetInstances( string $lifetime ): void;

Remove instances based on lifetime

unsetParameter()

public function unsetParameter( string $name ): void;

Remove a parameter

Container\ContainerFactory

ClassSource on GitHub

Uses Phalcon\Contracts\Container\Ioc\IocContainerFactory · Phalcon\Contracts\Container\Service\Provider

Method Summary

Properties

protectedarray<array-key, Provider>$providers = []

Methods

Public · 2

addProvider()

public function addProvider( Provider $provider ): static;

Adds a provider

newContainer()

public function newContainer(): Container;

Returns a new container

Container\Definition\DefinitionType

ClassSource on GitHub
  • Phalcon\Container\Definition\DefinitionType

Constants

stringCLOSURE_TYPE = "closure"
stringOBJECT_TYPE = "object"
stringPARAMETER_TYPE = "parameter"
stringSTRING_TYPE = "string"

Container\Definition\Processor\ClosureProcessor

ClassSource on GitHub

Uses Closure · Phalcon\Container\Definition\DefinitionType · Phalcon\Container\Definition\ServiceDefinition

Method Summary

Methods

Public · 2

canProcess()

public function canProcess( mixed $definition ): bool;

Wheteher the definition is a Closure

process()

public function process(
    string $name,
    mixed $definition,
    object $container
): ServiceDefinition;

Process the Closure

Container\Definition\Processor\ObjectProcessor

ClassSource on GitHub

Uses Closure · Phalcon\Container\Definition\DefinitionType · Phalcon\Container\Definition\ServiceDefinition

Method Summary

Methods

Public · 2

canProcess()

public function canProcess( mixed $definition ): bool;

Whether the definition is an Object (not Closure)

process()

public function process(
    string $name,
    mixed $definition,
    object $container
): ServiceDefinition;

Process the Object

Container\Definition\Processor\ParameterProcessor

ClassSource on GitHub

Uses Closure · Phalcon\Container\Definition\DefinitionType · Phalcon\Container\Definition\ServiceDefinition

Method Summary

Methods

Public · 2

canProcess()

public function canProcess( mixed $definition ): bool;

Whetehr the definition is a parameter

process()

public function process(
    string $name,
    mixed $definition,
    object $container
): ServiceDefinition;

Process the parameter

Container\Definition\Processor\Processor

InterfaceSource on GitHub
  • Phalcon\Container\Definition\Processor\Processor

Uses Phalcon\Container\Definition\ServiceDefinition

Method Summary

Methods

Public · 2

canProcess()

public function canProcess( mixed $definition ): bool;

Can this definition be processed?

process()

public function process(
    string $name,
    mixed $definition,
    object $container
): ServiceDefinition;

Process the definition

Container\Definition\Processor\StringProcessor

ClassSource on GitHub

Uses Phalcon\Container\Definition\DefinitionType · Phalcon\Container\Definition\ServiceDefinition

Method Summary

Methods

Public · 2

canProcess()

public function canProcess( mixed $definition ): bool;

Whether the definition is a class string

process()

public function process(
    string $name,
    mixed $definition,
    object $container
): ServiceDefinition;

Process the class string

Container\Definition\ServiceDefinition

ClassSource on GitHub
  • Phalcon\Container\Definition\ServiceDefinition

Uses Phalcon\Container\Exceptions\FrozenDefinition · Phalcon\Container\Exceptions\InvalidExtender · Phalcon\Container\Exceptions\NoClassSet · Phalcon\Container\Exceptions\NoFactorySet · ReflectionClass · ReflectionException

Method Summary

Properties

protectedarray$arguments = []
protectedstring | null$className = null
protectedarray$constructorArgs = []
protectedobject | null$container = null
protectedarray<array-key, callable>$extenders = []
protectedcallable | null$factory = null
protectedbool$frozen = false
protectedbool$isCacheable = false
protectedstring$lifetime = ServiceLifetime::SCOPED
protectedmixed$raw = null
protectedmixed$serviceName
protectedarray$tags = []
protectedmixed$type

Methods

Public · 29

__construct()

public function __construct(
    string $serviceName,
    string $type,
    mixed $raw = null
);

addExtender()

public function addExtender( callable $extender ): static;

Adds an extender

addTag()

public function addTag( string $tag ): static;

Adds a tag

buildService()

public function buildService( object $container ): object;

Builds a service and returns the instance back

freeze()

public function freeze( object $container ): void;

Freezes the container

getArguments()

public function getArguments(): array;

Returns the arguments

getClass()

public function getClass(): string;

Returns the class

getConstructorArgs()

public function getConstructorArgs(): array;

Returns the constructor arguments

getExtenders()

public function getExtenders(): array;

Returns the extenders

getFactory()

public function getFactory(): callable;

Returns the factory

getLifetime()

public function getLifetime(): string;

Returns the lifetime

getServiceName()

public function getServiceName(): string;

Returns the name of the service

getTags()

public function getTags(): array;

Returns the tags

getType()

public function getType(): string;

Returns the type

hasClass()

public function hasClass(): bool;

Does it have a class

hasExtenders()

public function hasExtenders(): bool;

Do we have extenders

hasFactory()

public function hasFactory(): bool;

Does it have a factory

isCacheable()

public function isCacheable(): bool;

Is it cacheable

isFrozen()

public function isFrozen(): bool;

Is it frozen

setArgument()

public function setArgument(
    mixed $param,
    mixed $value
): static;

Set an argument

setClass()

public function setClass( string $className ): static;

Set a class

setContainer()

public function setContainer( object $container ): static;

Set the container

setExtenders()

public function setExtenders( array $extenders ): static;

Set extenders

setFactory()

public function setFactory( callable $factory ): static;

Set a factory

setIsCacheable()

public function setIsCacheable( bool $isCacheable ): static;

Set cachable

setLifetime()

public function setLifetime( string $lifetime ): static;

Set lifetime

unsetClass()

public function unsetClass(): static;

Unset class

unsetExtenders()

public function unsetExtenders(): static;

Unset extenders

unsetFactory()

public function unsetFactory(): static;

Unset the factory

Protected · 1

checkFrozen()

protected function checkFrozen(): void;

Check if frozen

Container\Definition\ServiceLifetime

ClassSource on GitHub
  • Phalcon\Container\Definition\ServiceLifetime

Constants

stringSCOPED = "SCOPED"
stringSINGLETON = "SINGLETON"
stringTRANSIENT = "TRANSIENT"

Container\Exceptions\CannotExtendResolved

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

Cannot extend a resolved service

Container\Exceptions\CannotResolveParameter

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct(
    string $param,
    string $className
);

Cannot resolve a parameter

Container\Exceptions\CircularAliasFound

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

Circular Alias found

Container\Exceptions\ContainerThrowable

InterfaceSource on GitHub

Uses Phalcon\Contracts\Container\Ioc\IocThrowable · Phalcon\Contracts\Container\Resolver\ResolverThrowable · Phalcon\Contracts\Container\Service\Throwable

Container\Exceptions\EnvNotDefined

FinalSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $varname );

Container\Exceptions\Exception

ClassSource on GitHub

Uses Exception

Container\Exceptions\FrozenDefinition

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

Definition is frozen

Container\Exceptions\InstanceNotFound

FinalSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

Container\Exceptions\InvalidExtender

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct(
    string $service,
    string $key
);

Invalid extender (not callable)

Container\Exceptions\NoClassSet

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

No set for service

Container\Exceptions\NoFactorySet

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

No factory for service

Container\Exceptions\NoProcessorFound

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct();

No processor found

Container\Exceptions\ParameterNotFound

FinalSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

Container\Exceptions\ServiceNotFound

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

Service not found

Container\Exceptions\ServiceNotRegistered

ClassSource on GitHub

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $name );

Service not registered

Container\Provider\Cli

ClassSource on GitHub

Uses Phalcon\Auth\Access\AccessLocator · Phalcon\Contracts\Container\Service\Collection · Phalcon\Contracts\Container\Service\Provider · Phalcon\Filter\Filter · Phalcon\Filter\FilterFactory

Method Summary

Methods

Public · 1

provide()

public function provide( Collection $services ): void;

Provider for commonly used CLI applications

Container\Provider\Web

ClassSource on GitHub

Uses Phalcon\Auth\Access\AccessLocator · Phalcon\Contracts\Container\Service\Collection · Phalcon\Contracts\Container\Service\Provider · Phalcon\Filter\Filter · Phalcon\Filter\FilterFactory

Method Summary

Methods

Public · 1

provide()

public function provide( Collection $services ): void;

Provider for commonly used Web applications

Container\Resolver\Lazy\ArrayValues

ClassSource on GitHub

Uses ArrayAccess · ArrayIterator · Countable · IteratorAggregate

Method Summary

Properties

protectedarray<array-key, mixed>$values = []

Methods

Public · 9

__construct()

public function __construct( array $values = [] );

count()

public function count(): int;

getIterator()

public function getIterator(): ArrayIterator;

merge()

public function merge( mixed $values ): void;

offsetExists()

public function offsetExists( mixed $offset ): bool;

offsetGet()

public function offsetGet( mixed $offset ): mixed;

offsetSet()

public function offsetSet(
    mixed $offset,
    mixed $value
): void;

offsetUnset()

public function offsetUnset( mixed $offset ): void;

resolve()

public function resolve( object $ioc ): array;

Resolve to an array, where each element has itself been lazy-resolved.

Protected · 2

resolveValue()

protected function resolveValue(
    object $ioc,
    mixed $value
): mixed;

resolveValues()

protected function resolveValues(
    object $ioc,
    array $values
): array;

Container\Resolver\Lazy\Call

ClassSource on GitHub

Method Summary

Properties

protectedmixed$callableObject

Methods

Public · 2

__construct()

public function __construct( callable $callableObject );

resolve()

public function resolve( object $ioc ): mixed;

Resolve the callable

Container\Resolver\Lazy\CallableGet

ClassSource on GitHub

Method Summary

Properties

protectedstring|Lazy$id

Methods

Public · 2

__construct()

public function __construct( mixed $id );

resolve()

public function resolve( object $ioc ): mixed;

Resolve to a closure on a get()

Container\Resolver\Lazy\CallableNew

ClassSource on GitHub

Method Summary

Properties

protectedstring|Lazy$id

Methods

Public · 2

__construct()

public function __construct( mixed $id );

resolve()

public function resolve( object $ioc ): mixed;

Resolve to a closure on a new()

Container\Resolver\Lazy\CsEnv

ClassSource on GitHub

Uses Phalcon\Container\Exceptions\EnvNotDefined

Method Summary

Methods

Public · 1

resolve()

public function resolve( object $ioc ): array;

Resolve the getEnv() from keys as a comma separated list

Container\Resolver\Lazy\Env

ClassSource on GitHub

Uses Phalcon\Container\Exceptions\EnvNotDefined

Method Summary

Properties

protectedstring$varname
protectedstring|null$vartype = null

Methods

Public · 2

__construct()

public function __construct(
    string $varname,
    string $vartype = null
);

resolve()

public function resolve( object $ioc ): mixed;

Resolve an environment variable

Protected · 2

cast()

protected function cast( mixed $value ): mixed;

Cast a value to the defined type (if any)

getEnv()

protected function getEnv(): string;

Return the env value

Container\Resolver\Lazy\EnvDefault

ClassSource on GitHub

Uses Phalcon\Container\Exceptions\EnvNotDefined

Method Summary

Methods

Public · 2

__construct()

public function __construct(
    string $varname,
    mixed $defaultValue,
    string $vartype = null
);

resolve()

public function resolve( object $ioc ): mixed;

Resolve an environment variable, returning the default if not defined

Container\Resolver\Lazy\FunctionCall

ClassSource on GitHub

Method Summary

Properties

protectedarray<array-key, mixed>$arguments
protectedstring$functionName

Methods

Public · 2

__construct()

public function __construct(
    string $functionName,
    array $arguments
);

resolve()

public function resolve( object $ioc ): mixed;

Resolve a function

Container\Resolver\Lazy\Get

ClassSource on GitHub

Method Summary

Properties

protectedstring|Lazy$id

Methods

Public · 2

__construct()

public function __construct( mixed $id );

resolve()

public function resolve( object $ioc ): mixed;

Resolve a shared instance

Container\Resolver\Lazy\GetCall

ClassSource on GitHub

Method Summary

Properties

protectedarray<array-key, mixed>$arguments
protectedstring|Lazy$id
protectedstring$method

Methods

Public · 2

__construct()

public function __construct(
    mixed $id,
    string $method,
    array $arguments
);

resolve()

public function resolve( object $ioc ): mixed;

Resolve a shared instance method call

Container\Resolver\Lazy\Lazy

AbstractSource on GitHub

Uses Phalcon\Contracts\Container\Resolver\Resolvable

Method Summary

Methods

Public · 2

__invoke()

public function __invoke( object $ioc ): mixed;

resolve()

abstract public function resolve( object $ioc ): mixed;
Protected · 2

resolveArgument()

protected function resolveArgument(
    object $ioc,
    mixed $argument
): mixed;

resolveArguments()

protected function resolveArguments(
    object $ioc,
    array $arguments
): array;

Container\Resolver\Lazy\LazyFactory

ClassSource on GitHub
  • Phalcon\Container\Resolver\Lazy\LazyFactory

Method Summary

Methods

Public · 13

arrayValues()

public static function arrayValues( array $values ): ArrayValues;

call()

public static function call( callable $callableObject ): Call;

callableGet()

public static function callableGet( string $id ): CallableGet;

callableNew()

public static function callableNew( string $id ): CallableNew;

csEnv()

public static function csEnv(
    string $name,
    string $type = null
): CsEnv;

env()

public static function env(
    string $name,
    string $type = null
): Env;

envDefault()

public static function envDefault(
    string $name,
    mixed $defaultValue,
    string $type = null
): EnvDefault;

functionCall()

public static function functionCall(
    string $functionName,
    array $args
): FunctionCall;

get()

public static function get( string $id ): Get;

getCall()

public static function getCall(
    string $id,
    string $method,
    array $args
): GetCall;

newCall()

public static function newCall(
    string $id,
    string $method,
    array $args
): NewCall;

newInstance()

public static function newInstance( string $id ): NewInstance;

staticCall()

public static function staticCall(
    string $className,
    string $method,
    array $args
): StaticCall;

Container\Resolver\Lazy\NewCall

ClassSource on GitHub

Method Summary

Properties

protectedarray<array-key, mixed>$arguments
protectedstring|Lazy$id
protectedstring$method

Methods

Public · 2

__construct()

public function __construct(
    mixed $id,
    string $method,
    array $arguments
);

resolve()

public function resolve( object $ioc ): mixed;

Resolve a new instance method call

Container\Resolver\Lazy\NewInstance

ClassSource on GitHub

Method Summary

Properties

protectedstring|Lazy$id

Methods

Public · 2

__construct()

public function __construct( mixed $id );

resolve()

public function resolve( object $ioc ): mixed;

Resolve a new instance

Container\Resolver\Lazy\StaticCall

ClassSource on GitHub

Method Summary

Properties

protectedarray<array-key, mixed>$arguments
protectedstring|Lazy$className
protectedstring$method

Methods

Public · 2

__construct()

public function __construct(
    mixed $className,
    string $method,
    array $arguments
);

resolve()

public function resolve( object $ioc ): mixed;

Resolve a static method call

Container\Resolver\Resolver

ClassSource on GitHub

Uses Closure · Phalcon\Container\Exceptions\CannotResolveParameter · Phalcon\Container\Resolver\Lazy\Lazy · Phalcon\Contracts\Container\Resolver\ResolverService · ReflectionClass · ReflectionException · ReflectionFunction · ReflectionMethod · ReflectionNamedType · ReflectionParameter · ReflectionType

Method Summary

Methods

Public · 7

isResolvableClass()

public function isResolvableClass( string $className ): bool;

Is this a resolvable class?

resolveCall()

public function resolveCall(
    object $ioc,
    callable $callableObject,
    array $arguments
): mixed;

Resolve a call

resolveClass()

public function resolveClass(
    object $ioc,
    string $className,
    array $arguments
): object;

Resolve a class

resolveMethod()

public function resolveMethod(
    object $ioc,
    ReflectionMethod $method,
    object $instance
): void;

Resolve a method

resolveParameter()

public function resolveParameter(
    object $ioc,
    ReflectionParameter $parameter
): mixed;

Resolve parameters

resolveParameters()

public function resolveParameters(
    object $ioc,
    array $parameters,
    array $arguments
): array;

resolveType()

public function resolveType(
    object $ioc,
    mixed $type
): mixed;

type is ReflectionType

Type to search…

↑↓ navigate↵ selectEsc close