ConnectionFactory
class ConnectionFactory
Properties
| protected array<string, callable> | $extensions | The custom connection resolvers. |
Methods
Establish a PDO connection based on the configuration.
Register an extension connection resolver.
Remove an extension connection resolver.
Create an in-memory SQLite connection using a shared PDO.
Parse and prepare the database configuration.
Determine if the configuration has a read side.
Get the single-role read configuration for a read / write connection.
Create a single database connection instance.
Create a read / write database connection instance.
Create a new PDO instance for reading.
Get the read configuration for a read / write connection.
Get the write configuration for a read / write connection.
Get a read / write level configuration.
Merge a configuration for a read / write connection.
Create a new Closure that resolves to a PDO instance.
Create a new Closure that resolves to a PDO instance with a specific host or an array of hosts.
Parse the hosts configuration item into an array.
Create a new Closure that resolves to a PDO instance where there is no configured host.
Create a connector instance based on the configuration.
Create a new connection instance.
Details
at line 33
__construct(Container $container)
Create a new connection factory instance.
at line 41
Connection
make(array $config, string|null $name = null)
Establish a PDO connection based on the configuration.
at line 74
void
extend(string $name, callable $resolver)
Register an extension connection resolver.
Boot-only. The resolver persists in the singleton factory's extensions array for the worker lifetime and applies to every subsequent connection.
at line 86
void
forgetExtension(string $name)
Remove an extension connection resolver.
Boot or tests only. Mutates the singleton factory's extensions array; concurrent coroutines establishing connections may see the resolver removed mid-resolution.
at line 101
Connection
makeSqliteFromSharedPdo(PDO $pdo, array $config, string|null $name = null)
Create an in-memory SQLite connection using a shared PDO.
Used by connection pooling for in-memory SQLite where all pool slots must share the same PDO instance to see the same data. Without this, each pooled connection would get its own empty in-memory database.
Returns Connection (not SQLiteConnection) to respect custom resolvers that may return a different Connection subclass.
at line 123
array
parseConfig(array $config, string|null $name)
Parse and prepare the database configuration.
at line 133
bool
hasReadConfig(array $config)
Determine if the configuration has a read side.
at line 141
array
configForRead(array $config)
Get the single-role read configuration for a read / write connection.
at line 157
protected Connection
createSingleConnection(array $config)
Create a single database connection instance.
at line 173
protected Connection
createReadWriteConnection(array $config)
Create a read / write database connection instance.
at line 185
protected Closure
createReadPdo(array $config)
Create a new PDO instance for reading.
at line 193
protected array
getReadConfig(array $config)
Get the read configuration for a read / write connection.
at line 204
protected array
getWriteConfig(array $config)
Get the write configuration for a read / write connection.
at line 215
protected array
getReadWriteConfig(array $config, string $type)
Get a read / write level configuration.
at line 225
protected array
mergeReadWriteConfig(array $config, array $merge)
Merge a configuration for a read / write connection.
at line 233
protected Closure
createPdoResolver(array $config)
Create a new Closure that resolves to a PDO instance.
at line 243
protected Closure
createPdoResolverWithHosts(array $config)
Create a new Closure that resolves to a PDO instance with a specific host or an array of hosts.
at line 267
protected array
parseHosts(array $config)
Parse the hosts configuration item into an array.
at line 281
protected Closure
createPdoResolverWithoutHosts(array $config)
Create a new Closure that resolves to a PDO instance where there is no configured host.
at line 291
ConnectorInterface
createConnector(array $config)
Create a connector instance based on the configuration.
at line 315
protected Connection
createConnection(string $driver, PDO|Closure $connection, string $database, string $prefix = '', array $config = [])
Create a new connection instance.