DatabaseDefinitions
What the compiled databases configuration declares, as data.
The compiled form used to be statements required inside DatabaseManager::initialize(), assigning into $this->databases and $this->defaultDatabaseName from a scope it had no business reaching. It is a declaration now, for the same reasons the compiled factories configuration is — see FactoryDefinitions.
Synopsis
Section titled “Synopsis”final readonly class DatabaseDefinitions
| Since | 4.0.0 |
| Source | Database/DatabaseDefinitions.php |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
$databases | array | readonly. |
$default | string | readonly. |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(array<string, array{class: class-string<Database>, parameters: array<string, mixed>}> $databases, string $default): mixed
The connection answered when none is named.
| Parameter | Type | Description |
|---|---|---|
$databases | array``<``string``, ``array{class: class-string<Database>, parameters: array<string, mixed>}``> | Keyed by connection name, in declaration order. |
$default | string | The connection answered when none is named. |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
fromCompiled(mixed $compiled, string $source = 'the compiled databases cache'): DatabaseDefinitions | Read a compiled declaration, rejecting anything malformed. |
fromCompiled()
Section titled “fromCompiled()”public static function fromCompiled(mixed $compiled, string $source = 'the compiled databases cache'): DatabaseDefinitions
Read a compiled declaration, rejecting anything malformed.
Whatever the compiled file returned.
| Parameter | Type | Description |
|---|---|---|
$compiled | mixed | Whatever the compiled file returned. |
$source | string |
Returns DatabaseDefinitions
| Throws | When |
|---|---|
ConfigurationException | When $compiled is not a declaration this version understands — most likely a cache compiled by an earlier one. |