forked from php-db/phpdb-pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigProvider.php
More file actions
100 lines (94 loc) · 4.18 KB
/
ConfigProvider.php
File metadata and controls
100 lines (94 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
declare(strict_types=1);
namespace PhpDb\Pgsql;
use PhpDb\Adapter\AdapterInterface;
use PhpDb\Adapter\Driver\ConnectionInterface;
use PhpDb\Adapter\Driver\DriverInterface;
use PhpDb\Adapter\Driver\Pdo\Statement as PdoStatement;
use PhpDb\Adapter\Driver\PdoConnectionInterface;
use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Platform\PlatformInterface;
use PhpDb\ConfigProvider as PhpDbConfigProvider;
use PhpDb\Metadata\MetadataInterface;
use PhpDb\Pgsql\Pdo\Connection as PdoConnection;
use PhpDb\Pgsql\Pdo\Driver as PdoDriver;
/**
* @internal
*/
final readonly class ConfigProvider
{
public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
//AdapterInterface::class => $this->getConfig(),
];
}
public function getConfig(): array
{
return [
// Standard Single Adapter configuration
'driver' => Driver::class,
'connection' => [
'host' => 'localhost',
'port' => 5432,
'username' => 'your_username',
'password' => 'your_password',
'database' => 'your_database',
],
// Named Adapter configurations
PhpDbConfigProvider::NAMED_ADAPTER_KEY => [
AdapterInterface::class => [
'driver' => Driver::class,
'connection' => [
'host' => 'localhost',
'port' => 5432,
'username' => 'your_username',
'password' => 'your_password',
'database' => 'your_database',
],
],
],
];
}
public function getDependencies(): array
{
return [
'aliases' => [
DriverInterface::class => Driver::class,
'pgsql' => Driver::class,
'PgSQL' => Driver::class,
'Postgresql' => Driver::class,
'PostgreSQL' => Driver::class,
PdoDriverInterface::class => PdoDriver::class,
'pdo_pgsql' => PdoDriver::class,
'PDO_pgsql' => PdoDriver::class,
'PDO_PgSQL' => PdoDriver::class,
'Pdo_PgSQL' => PdoDriver::class,
'PDO_postgresql' => PdoDriver::class,
'pdo_postgresql' => PdoDriver::class,
'PDO_Postgresql' => PdoDriver::class,
'Pdo_Postgresql' => PdoDriver::class,
'PDO_PostgreSQL' => PdoDriver::class,
ConnectionInterface::class => Connection::class,
MetadataInterface::class => Metadata\Source::class,
PdoConnectionInterface::class => PdoConnection::class,
PlatformInterface::class => AdapterPlatform::class,
],
'factories' => [
AdapterPlatform::class => Container\PlatformInterfaceFactory::class,
Connection::class => Container\ConnectionInterfaceFactory::class,
Driver::class => Container\DriverInterfaceFactory::class,
Metadata\Source::class => Container\MetadataInterfaceFactory::class,
PdoConnection::class => Container\PdoConnectionInterfaceFactory::class,
PdoDriver::class => Container\PdoDriverInterfaceFactory::class,
PdoStatement::class => Container\PdoStatementFactory::class,
Statement::class => Container\StatementInterfaceFactory::class,
// Provide the following if you wish to override the Profiler implementation
//ProfilerInterface::class => YourCustomProfilerFactory::class,
// Provide the following if you wish to override the ResultSet implementation
//ResultSetInterface::class => YourCustomResultSetFactory::class,
],
];
}
}