环境版本支持
| hyperf框架版本 | php版本 | database版本 |
|---|---|---|
| 2.2 | >=7.4 | ~2.2.0 |
| 3.0 | >=8.1 | ~3.0.0 |
https://github.com/hyperf/database-pgsql-incubator
hyperf/database 组件版本必须大于等于 v2.2.26
composer require hyperf/database-pgsql-incubator
https://github.com/hyperf/database-pgsql
composer.json中加入以下两个扩展包
"hyperf/database-pgsql": "^3.0", // 这里增加pgsql 驱动
"hyperf/db": "^3.0", // 3.0 以上 官方才支持
修改 autoload/database.php 配置
return [
'pgsql' => [
'driver' => 'pgsql',
'host' => '127.0.0.1',
'database' => 'hyperf',
'port' => 5435,
'username' => 'postgres',
'password' => "",
'charset' => env('DB_CHARSET', 'utf8'),
'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
'prefix' => '',
'schema' => 'public',
'pool' => [
'min_connections' => 1,
'max_connections' => 10,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
],
'commands' => [
'gen:model' => [
'path' => 'app/Model',
'force_casts' => false,
'inheritance' => 'Model',
'refresh_fillable' => true
],
],
],
'pgsql-swoole' => [
'driver' => 'pgsql-swoole',
'host' => '127.0.0.1',
'database' => 'hyperf',
'port' => 5435,
'username' => 'postgres',
'password' => "",
'charset' => env('DB_CHARSET', 'utf8'),
'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
'prefix' => '',
'schema' => 'public',
'pool' => [
'min_connections' => 1,
'max_connections' => 10,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
],
'commands' => [
'gen:model' => [
'path' => 'app/Model',
'force_casts' => false,
'inheritance' => 'Model',
'refresh_fillable' => true
],
],
],
];