PHP Класс DI\ContainerBuilder

With the default options, the container created is appropriate for the development environment. Example: $builder = new ContainerBuilder(); $container = $builder->build();
С версии: 3.2
Автор: Matthieu Napoli ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( string $containerClass = 'DI\Container' )
addDefinitions ( string | array | DI\Definition\Source\DefinitionSource $definitions ) Add definitions to the container.
build ( ) : Container Build and return a container.
buildDevContainer ( ) : Container Build a container configured for the dev environment.
ignorePhpDocErrors ( boolean $bool ) : ContainerBuilder Enable or disable ignoring phpdoc errors (non-existent classes in @param or @var).
setDefinitionCache ( Doctrine\Common\Cache\Cache $cache ) : ContainerBuilder Enables the use of a cache for the definitions.
useAnnotations ( boolean $bool ) : ContainerBuilder Enable or disable the use of annotations to guess injections.
useAutowiring ( boolean $bool ) : ContainerBuilder Enable or disable the use of autowiring to guess injections.
wrapContainer ( Interop\Container\ContainerInterface $otherContainer ) If PHP-DI's container is wrapped by another container, we can set this so that PHP-DI will use the wrapper rather than itself for building objects.
writeProxiesToFile ( boolean $writeToFile, string | null $proxyDirectory = null ) : ContainerBuilder Configure the proxy generation.

Приватные методы

Метод Описание
ensureNotLocked ( )

Описание методов

__construct() публичный Метод

public __construct ( string $containerClass = 'DI\Container' )
$containerClass string Name of the container class, used to create the container.

addDefinitions() публичный Метод

Add definitions to the container.
public addDefinitions ( string | array | DI\Definition\Source\DefinitionSource $definitions )
$definitions string | array | DI\Definition\Source\DefinitionSource Can be an array of definitions, the name of a file containing definitions or a DefinitionSource object.

build() публичный Метод

Build and return a container.
public build ( ) : Container
Результат Container

buildDevContainer() публичный статический Метод

Build a container configured for the dev environment.
public static buildDevContainer ( ) : Container
Результат Container

ignorePhpDocErrors() публичный Метод

Enable or disable ignoring phpdoc errors (non-existent classes in @param or @var).
public ignorePhpDocErrors ( boolean $bool ) : ContainerBuilder
$bool boolean
Результат ContainerBuilder

setDefinitionCache() публичный Метод

Enables the use of a cache for the definitions.
public setDefinitionCache ( Doctrine\Common\Cache\Cache $cache ) : ContainerBuilder
$cache Doctrine\Common\Cache\Cache Cache backend to use
Результат ContainerBuilder

useAnnotations() публичный Метод

Disabled by default.
public useAnnotations ( boolean $bool ) : ContainerBuilder
$bool boolean
Результат ContainerBuilder

useAutowiring() публичный Метод

Enabled by default.
public useAutowiring ( boolean $bool ) : ContainerBuilder
$bool boolean
Результат ContainerBuilder

wrapContainer() публичный Метод

If PHP-DI's container is wrapped by another container, we can set this so that PHP-DI will use the wrapper rather than itself for building objects.
public wrapContainer ( Interop\Container\ContainerInterface $otherContainer )
$otherContainer Interop\Container\ContainerInterface

writeProxiesToFile() публичный Метод

For dev environment, use writeProxiesToFile(false) (default configuration) For production environment, use writeProxiesToFile(true, 'tmp/proxies')
public writeProxiesToFile ( boolean $writeToFile, string | null $proxyDirectory = null ) : ContainerBuilder
$writeToFile boolean If true, write the proxies to disk to improve performances
$proxyDirectory string | null Directory where to write the proxies
Результат ContainerBuilder