Documentation

Configuration extends Configuration
in package

Configuration container for all configuration options of Doctrine.

It combines all configuration options from DBAL & ORM.

Internal note: When adding a new configuration option just write a getter/setter pair.

Tags
psalm-import-type

AutogenerateMode from ProxyFactory

Table of Contents

Properties

$_attributes  : array<string|int, mixed>
$autoCommit  : bool
The default auto-commit mode for connections.
$resultCacheImpl  : Cache|null
The cache driver implementation that is used for query result caching.
$schemaAssetsFilter  : callable|null
The callable to use to filter schema assets.
$sqlLogger  : SQLLogger|null
The SQL logger in use. If null, SQL logging is disabled.
$middlewares  : array<string|int, Middleware>
$resultCache  : CacheItemPoolInterface|null
The cache driver implementation that is used for query result caching.
$schemaManagerFactory  : SchemaManagerFactory|null

Methods

__construct()  : mixed
addCustomDatetimeFunction()  : void
Registers a custom DQL function that produces a date/time value.
addCustomHydrationMode()  : void
Adds a custom hydration mode.
addCustomNumericFunction()  : void
Registers a custom DQL function that produces a numeric value.
addCustomStringFunction()  : void
Registers a custom DQL function that produces a string value.
addEntityNamespace()  : void
addFilter()  : void
Adds a filter to the list of possible filters.
addNamedNativeQuery()  : void
Adds a named native query to the configuration.
addNamedQuery()  : void
Adds a named DQL query to the configuration.
ensureProductionSettings()  : void
Ensures that this Configuration instance contains settings that are suitable for a production environment.
getAutoCommit()  : bool
Returns the default auto-commit mode for connections.
getAutoGenerateProxyClasses()  : int
Gets the strategy for automatically generating proxy classes.
getClassMetadataFactoryName()  : string
getCustomDatetimeFunction()  : string|callable|null
Gets the implementation class name of a registered custom date/time DQL function.
getCustomHydrationMode()  : string|null
Gets the hydrator class for the given hydration mode name.
getCustomNumericFunction()  : string|callable|null
Gets the implementation class name of a registered custom numeric DQL function.
getCustomStringFunction()  : string|callable|null
Gets the implementation class name of a registered custom string DQL function.
getDefaultQueryHint()  : mixed
Gets the value of a default query hint. If the hint name is not recognized, FALSE is returned.
getDefaultQueryHints()  : mixed
Returns query hints, which will be applied to every query in application
getDefaultRepositoryClassName()  : string
Get default repository class.
getEntityListenerResolver()  : EntityListenerResolver
Get the entity listener resolver.
getEntityNamespace()  : string
Resolves a registered namespace alias to the full namespace.
getEntityNamespaces()  : mixed
Retrieves the list of registered entity namespace aliases.
getFilterClassName()  : string|null
Gets the class name for a given filter name.
getHydrationCache()  : CacheItemPoolInterface|null
getHydrationCacheImpl()  : Cache|null
Gets the cache driver implementation that is used for the hydration cache (SQL cache).
getMetadataCache()  : CacheItemPoolInterface|null
getMetadataCacheImpl()  : Cache|null
Gets the cache driver implementation that is used for metadata caching.
getMetadataDriverImpl()  : MappingDriver|null
Gets the cache driver implementation that is used for the mapping metadata.
getMiddlewares()  : array<string|int, Middleware>
getNamedNativeQuery()  : array<string|int, mixed>
Gets the components of a previously registered named native query.
getNamedQuery()  : string
Gets a previously registered named DQL query.
getNamingStrategy()  : NamingStrategy
Gets naming strategy.
getProxyDir()  : string|null
Gets the directory where Doctrine generates any necessary proxy class files.
getProxyNamespace()  : string|null
Gets the namespace where proxy classes reside.
getQueryCache()  : CacheItemPoolInterface|null
Gets the cache driver implementation that is used for the query cache (SQL cache).
getQueryCacheImpl()  : Cache|null
Gets the cache driver implementation that is used for the query cache (SQL cache).
getQuoteStrategy()  : QuoteStrategy
Gets quote strategy.
getRepositoryFactory()  : RepositoryFactory
Get the entity repository factory.
getResultCache()  : CacheItemPoolInterface|null
Gets the cache driver implementation that is used for query result caching.
getResultCacheImpl()  : Cache|null
Gets the cache driver implementation that is used for query result caching.
getSchemaAssetsFilter()  : callable|null
Returns the callable to use to filter schema assets.
getSchemaIgnoreClasses()  : array<int, class-string>
Gets a list of entity class names to be ignored by the SchemaTool
getSchemaManagerFactory()  : SchemaManagerFactory|null
getSecondLevelCacheConfiguration()  : CacheConfiguration|null
getSQLLogger()  : SQLLogger|null
Gets the SQL logger that is used.
getTypedFieldMapper()  : TypedFieldMapper|null
Gets a TypedFieldMapper for php typed fields to DBAL types auto-completion.
isLazyGhostObjectEnabled()  : bool
isSecondLevelCacheEnabled()  : bool
newDefaultAnnotationDriver()  : AnnotationDriver
Adds a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported.
setAutoCommit()  : void
Sets the default auto-commit mode for connections.
setAutoGenerateProxyClasses()  : void
Sets the strategy for automatically generating proxy classes.
setClassMetadataFactoryName()  : void
Sets a class metadata factory.
setCustomDatetimeFunctions()  : void
Sets a map of custom DQL date/time functions.
setCustomHydrationModes()  : void
Sets the custom hydrator modes in one pass.
setCustomNumericFunctions()  : void
Sets a map of custom DQL numeric functions.
setCustomStringFunctions()  : void
Sets a map of custom DQL string functions.
setDefaultQueryHint()  : void
Sets a default query hint. If the hint name is not recognized, it is silently ignored.
setDefaultQueryHints()  : void
Sets array of query hints, which will be applied to every query in application
setDefaultRepositoryClassName()  : void
Sets default repository class.
setEntityListenerResolver()  : void
Set the entity listener resolver.
setEntityNamespaces()  : void
Sets the entity alias map.
setHydrationCache()  : void
setHydrationCacheImpl()  : void
Sets the cache driver implementation that is used for the hydration cache (SQL cache).
setLazyGhostObjectEnabled()  : void
setMetadataCache()  : void
setMetadataCacheImpl()  : void
Sets the cache driver implementation that is used for metadata caching.
setMetadataDriverImpl()  : void
Sets the cache driver implementation that is used for metadata caching.
setMiddlewares()  : $this
setNamingStrategy()  : void
Sets naming strategy.
setProxyDir()  : void
Sets the directory where Doctrine generates any necessary proxy class files.
setProxyNamespace()  : void
Sets the namespace where proxy classes reside.
setQueryCache()  : void
Sets the cache driver implementation that is used for the query cache (SQL cache).
setQueryCacheImpl()  : void
Sets the cache driver implementation that is used for the query cache (SQL cache).
setQuoteStrategy()  : void
Sets quote strategy.
setRepositoryFactory()  : void
Set the entity repository factory.
setResultCache()  : void
Sets the cache driver implementation that is used for query result caching.
setResultCacheImpl()  : void
Sets the cache driver implementation that is used for query result caching.
setSchemaAssetsFilter()  : void
Sets the callable to use to filter schema assets.
setSchemaIgnoreClasses()  : void
Sets a list of entity class names to be ignored by the SchemaTool
setSchemaManagerFactory()  : $this
setSecondLevelCacheConfiguration()  : void
setSecondLevelCacheEnabled()  : void
setSQLLogger()  : void
Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
setTypedFieldMapper()  : void
Sets a TypedFieldMapper for php typed fields to DBAL types auto-completion.

Properties

$_attributes

protected array<string|int, mixed> $_attributes = []

$autoCommit

The default auto-commit mode for connections.

protected bool $autoCommit = true

$resultCacheImpl

The cache driver implementation that is used for query result caching.

protected Cache|null $resultCacheImpl
Tags
deprecated

Use $resultCache instead.

$schemaAssetsFilter

The callable to use to filter schema assets.

protected callable|null $schemaAssetsFilter

Methods

addCustomDatetimeFunction()

Registers a custom DQL function that produces a date/time value.

public addCustomDatetimeFunction(string $name, string|callable $className) : void

Such a function can then be used in any DQL statement in any place where date/time functions are allowed.

DQL function names are case-insensitive.

Parameters
$name : string

Function name.

$className : string|callable

Class name or a callable that returns the function.

Tags
psalm-param

class-string<FunctionNode>|callable(string):FunctionNode $className

addCustomHydrationMode()

Adds a custom hydration mode.

public addCustomHydrationMode(string $modeName, string $hydrator) : void
Parameters
$modeName : string

The hydration mode name.

$hydrator : string

The hydrator class name.

Tags
psalm-param

class-string<AbstractHydrator> $hydrator

addCustomNumericFunction()

Registers a custom DQL function that produces a numeric value.

public addCustomNumericFunction(string $name, class-string|callable $className) : void

Such a function can then be used in any DQL statement in any place where numeric functions are allowed.

DQL function names are case-insensitive.

Parameters
$name : string

Function name.

$className : class-string|callable

Class name or a callable that returns the function.

Tags
psalm-param

class-string<FunctionNode>|callable(string):FunctionNode $className

addCustomStringFunction()

Registers a custom DQL function that produces a string value.

public addCustomStringFunction(string $name, class-string|callable $className) : void

Such a function can then be used in any DQL statement in any place where string functions are allowed.

DQL function names are case-insensitive.

Parameters
$name : string

Function name.

$className : class-string|callable

Class name or a callable that returns the function.

Tags
psalm-param

class-string<FunctionNode>|callable(string):FunctionNode $className

addEntityNamespace()

public addEntityNamespace(string $alias, string $namespace) : void
Parameters
$alias : string
$namespace : string
Tags
deprecated

No replacement planned.

Adds a namespace under a certain alias.

addFilter()

Adds a filter to the list of possible filters.

public addFilter(string $name, string $className) : void
Parameters
$name : string

The name of the filter.

$className : string

The class name of the filter.

Tags
psalm-param

class-string<SQLFilter> $className

addNamedNativeQuery()

Adds a named native query to the configuration.

public addNamedNativeQuery(string $name, string $sql, ResultSetMapping $rsm) : void
Parameters
$name : string

The name of the query.

$sql : string

The native SQL query string.

$rsm : ResultSetMapping

The ResultSetMapping used for the results of the SQL query.

addNamedQuery()

Adds a named DQL query to the configuration.

public addNamedQuery(string $name, string $dql) : void
Parameters
$name : string

The name of the query.

$dql : string

The DQL query string.

ensureProductionSettings()

Ensures that this Configuration instance contains settings that are suitable for a production environment.

public ensureProductionSettings() : void
Tags
deprecated
throws
ProxyClassesAlwaysRegenerating
throws
CacheException

If a configuration setting has a value that is not suitable for a production environment.

getAutoCommit()

Returns the default auto-commit mode for connections.

public getAutoCommit() : bool
Tags
see
setAutoCommit
Return values
bool

True if auto-commit mode is enabled by default for connections, false otherwise.

getAutoGenerateProxyClasses()

Gets the strategy for automatically generating proxy classes.

public getAutoGenerateProxyClasses() : int
Tags
psalm-return

AutogenerateMode

Return values
int

Possible values are constants of Doctrine\ORM\Proxy\ProxyFactory.

getClassMetadataFactoryName()

public getClassMetadataFactoryName() : string
Tags
psalm-return

class-string

Return values
string

getCustomDatetimeFunction()

Gets the implementation class name of a registered custom date/time DQL function.

public getCustomDatetimeFunction(string $name) : string|callable|null
Parameters
$name : string
Tags
psalm-return

class-string|callable|null

Return values
string|callable|null

getCustomHydrationMode()

Gets the hydrator class for the given hydration mode name.

public getCustomHydrationMode(string $modeName) : string|null
Parameters
$modeName : string

The hydration mode name.

Tags
psalm-return

class-string<AbstractHydrator>|null

Return values
string|null

The hydrator class name.

getCustomNumericFunction()

Gets the implementation class name of a registered custom numeric DQL function.

public getCustomNumericFunction(string $name) : string|callable|null
Parameters
$name : string
Tags
psalm-return

class-string|callable|null

Return values
string|callable|null

getCustomStringFunction()

Gets the implementation class name of a registered custom string DQL function.

public getCustomStringFunction(string $name) : string|callable|null
Parameters
$name : string
Tags
psalm-return

class-string<FunctionNode>|callable(string):FunctionNode|null

Return values
string|callable|null

getDefaultQueryHint()

Gets the value of a default query hint. If the hint name is not recognized, FALSE is returned.

public getDefaultQueryHint(string $name) : mixed
Parameters
$name : string

The name of the hint.

Return values
mixed

The value of the hint or FALSE, if the hint name is not recognized.

getDefaultQueryHints()

Returns query hints, which will be applied to every query in application

public getDefaultQueryHints() : mixed
Tags
psalm-return

array<string, mixed>

getDefaultRepositoryClassName()

Get default repository class.

public getDefaultRepositoryClassName() : string
Tags
psalm-return

class-string<EntityRepository>

Return values
string

getEntityNamespace()

Resolves a registered namespace alias to the full namespace.

public getEntityNamespace(string $entityNamespaceAlias) : string
Parameters
$entityNamespaceAlias : string
Tags
throws
UnknownEntityNamespace
Return values
string

getEntityNamespaces()

Retrieves the list of registered entity namespace aliases.

public getEntityNamespaces() : mixed
Tags
psalm-return

array<string, string>

getFilterClassName()

Gets the class name for a given filter name.

public getFilterClassName(string $name) : string|null
Parameters
$name : string

The name of the filter.

Tags
psalm-return

class-string<SQLFilter>|null

Return values
string|null

The class name of the filter, or null if it is not defined.

getHydrationCacheImpl()

Gets the cache driver implementation that is used for the hydration cache (SQL cache).

public getHydrationCacheImpl() : Cache|null
Tags
deprecated

Call getHydrationCache() instead.

Return values
Cache|null

getMetadataCacheImpl()

Gets the cache driver implementation that is used for metadata caching.

public getMetadataCacheImpl() : Cache|null
Tags
deprecated

Deprecated in favor of getMetadataCache

Return values
Cache|null

getNamedNativeQuery()

Gets the components of a previously registered named native query.

public getNamedNativeQuery(string $name) : array<string|int, mixed>
Parameters
$name : string

The name of the query.

Tags
psalm-return

array{string, ResultSetMapping} A tuple with the first element being the SQL string and the second element being the ResultSetMapping.

throws
NamedNativeQueryNotFound
Return values
array<string|int, mixed>

getNamedQuery()

Gets a previously registered named DQL query.

public getNamedQuery(string $name) : string
Parameters
$name : string

The name of the query.

Tags
throws
NamedQueryNotFound
Return values
string

The DQL query.

getProxyDir()

Gets the directory where Doctrine generates any necessary proxy class files.

public getProxyDir() : string|null
Return values
string|null

getProxyNamespace()

Gets the namespace where proxy classes reside.

public getProxyNamespace() : string|null
Return values
string|null

getQueryCacheImpl()

Gets the cache driver implementation that is used for the query cache (SQL cache).

public getQueryCacheImpl() : Cache|null
Tags
deprecated

Call getQueryCache() instead.

Return values
Cache|null

getResultCacheImpl()

Gets the cache driver implementation that is used for query result caching.

public getResultCacheImpl() : Cache|null
Tags
deprecated

Use getResultCache() instead.

Return values
Cache|null

getSchemaAssetsFilter()

Returns the callable to use to filter schema assets.

public getSchemaAssetsFilter() : callable|null
Return values
callable|null

getSchemaIgnoreClasses()

Gets a list of entity class names to be ignored by the SchemaTool

public getSchemaIgnoreClasses() : array<int, class-string>
Return values
array<int, class-string>

isLazyGhostObjectEnabled()

public isLazyGhostObjectEnabled() : bool
Return values
bool

isSecondLevelCacheEnabled()

public isSecondLevelCacheEnabled() : bool
Return values
bool

newDefaultAnnotationDriver()

Adds a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported.

public newDefaultAnnotationDriver([string|array<string|int, string> $paths = [] ][, bool $useSimpleAnnotationReader = true ]) : AnnotationDriver
Parameters
$paths : string|array<string|int, string> = []
$useSimpleAnnotationReader : bool = true
Tags
deprecated

Use ORMSetup::createDefaultAnnotationDriver() instead.

psalm-param

string|list $paths

Return values
AnnotationDriver

setAutoCommit()

Sets the default auto-commit mode for connections.

public setAutoCommit(bool $autoCommit) : void

If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode.

Parameters
$autoCommit : bool

True to enable auto-commit mode; false to disable it

Tags
see
getAutoCommit

setAutoGenerateProxyClasses()

Sets the strategy for automatically generating proxy classes.

public setAutoGenerateProxyClasses(bool|int $autoGenerate) : void
Parameters
$autoGenerate : bool|int

Possible values are constants of Doctrine\ORM\Proxy\ProxyFactory.

Tags
psalm-param

bool|AutogenerateMode $autoGenerate True is converted to AUTOGENERATE_ALWAYS, false to AUTOGENERATE_NEVER.

setClassMetadataFactoryName()

Sets a class metadata factory.

public setClassMetadataFactoryName(string $cmfName) : void
Parameters
$cmfName : string
Tags
psalm-param

class-string $cmfName

setCustomDatetimeFunctions()

Sets a map of custom DQL date/time functions.

public setCustomDatetimeFunctions(array<string|int, mixed> $functions) : void

Keys must be function names and values the FQCN of the implementing class. The function names will be case-insensitive in DQL.

Any previously added date/time functions are discarded.

Parameters
$functions : array<string|int, mixed>

The map of custom DQL date/time functions.

Tags
psalm-param

array<string, class-string<FunctionNode>|callable(string):FunctionNode> $functions

setCustomHydrationModes()

Sets the custom hydrator modes in one pass.

public setCustomHydrationModes(array<string, AbstractHydrator>$modes) : void
Parameters
$modes : array<string, AbstractHydrator>>

An array of ($modeName => $hydrator).

setCustomNumericFunctions()

Sets a map of custom DQL numeric functions.

public setCustomNumericFunctions(array<string|int, mixed> $functions) : void

Keys must be function names and values the FQCN of the implementing class. The function names will be case-insensitive in DQL.

Any previously added numeric functions are discarded.

Parameters
$functions : array<string|int, mixed>
Tags
psalm-param

array<string, class-string> $functions The map of custom DQL numeric functions.

setCustomStringFunctions()

Sets a map of custom DQL string functions.

public setCustomStringFunctions(array<string|int, mixed> $functions) : void

Keys must be function names and values the FQCN of the implementing class. The function names will be case-insensitive in DQL.

Any previously added string functions are discarded.

Parameters
$functions : array<string|int, mixed>
Tags
psalm-param

array<string, class-string<FunctionNode>|callable(string):FunctionNode> $functions The map of custom DQL string functions.

setDefaultQueryHint()

Sets a default query hint. If the hint name is not recognized, it is silently ignored.

public setDefaultQueryHint(string $name, mixed $value) : void
Parameters
$name : string

The name of the hint.

$value : mixed

The value of the hint.

setDefaultQueryHints()

Sets array of query hints, which will be applied to every query in application

public setDefaultQueryHints(array<string|int, mixed> $defaultQueryHints) : void
Parameters
$defaultQueryHints : array<string|int, mixed>
Tags
psalm-param

array<string, mixed> $defaultQueryHints

setDefaultRepositoryClassName()

Sets default repository class.

public setDefaultRepositoryClassName(string $className) : void
Parameters
$className : string
Tags
psalm-param

class-string<EntityRepository> $className

throws
InvalidEntityRepository

If $classname is not an ObjectRepository.

setEntityNamespaces()

Sets the entity alias map.

public setEntityNamespaces(array<string|int, mixed> $entityNamespaces) : void
Parameters
$entityNamespaces : array<string|int, mixed>
Tags
psalm-param

array<string, string> $entityNamespaces

setHydrationCacheImpl()

Sets the cache driver implementation that is used for the hydration cache (SQL cache).

public setHydrationCacheImpl(Cache $cacheImpl) : void
Parameters
$cacheImpl : Cache
Tags
deprecated

Call setHydrationCache() instead.

setLazyGhostObjectEnabled()

public setLazyGhostObjectEnabled(bool $flag) : void
Parameters
$flag : bool

setMetadataCacheImpl()

Sets the cache driver implementation that is used for metadata caching.

public setMetadataCacheImpl(Cache $cacheImpl) : void
Parameters
$cacheImpl : Cache
Tags
deprecated

Deprecated in favor of setMetadataCache

setMetadataDriverImpl()

Sets the cache driver implementation that is used for metadata caching.

public setMetadataDriverImpl(MappingDriver $driverImpl) : void
Parameters
$driverImpl : MappingDriver
Tags
todo

Force parameter to be a Closure to ensure lazy evaluation (as soon as a metadata cache is in effect, the driver never needs to initialize).

setMiddlewares()

public setMiddlewares(array<string|int, Middleware$middlewares) : $this
Parameters
$middlewares : array<string|int, Middleware>
Return values
$this

setProxyDir()

Sets the directory where Doctrine generates any necessary proxy class files.

public setProxyDir(string $dir) : void
Parameters
$dir : string

setProxyNamespace()

Sets the namespace where proxy classes reside.

public setProxyNamespace(string $ns) : void
Parameters
$ns : string

setQueryCacheImpl()

Sets the cache driver implementation that is used for the query cache (SQL cache).

public setQueryCacheImpl(Cache $cacheImpl) : void
Parameters
$cacheImpl : Cache
Tags
deprecated

Call setQueryCache() instead.

setResultCacheImpl()

Sets the cache driver implementation that is used for query result caching.

public setResultCacheImpl(Cache $cacheImpl) : void
Parameters
$cacheImpl : Cache
Tags
deprecated

Use setResultCache() instead.

setSchemaAssetsFilter()

Sets the callable to use to filter schema assets.

public setSchemaAssetsFilter([callable|null $callable = null ]) : void
Parameters
$callable : callable|null = null

setSchemaIgnoreClasses()

Sets a list of entity class names to be ignored by the SchemaTool

public setSchemaIgnoreClasses(array<int, class-string> $schemaIgnoreClasses) : void
Parameters
$schemaIgnoreClasses : array<int, class-string>

List of entity class names

setSecondLevelCacheEnabled()

public setSecondLevelCacheEnabled([bool $flag = true ]) : void
Parameters
$flag : bool = true

setSQLLogger()

Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.

public setSQLLogger([SQLLogger|null $logger = null ]) : void
Parameters
$logger : SQLLogger|null = null
Tags
deprecated

Use setMiddlewares() and Middleware instead.

setTypedFieldMapper()

Sets a TypedFieldMapper for php typed fields to DBAL types auto-completion.

public setTypedFieldMapper(TypedFieldMapper|null $typedFieldMapper) : void
Parameters
$typedFieldMapper : TypedFieldMapper|null

        
On this page

Search results