jonas-elias / hyperf-oracle
A oracle handler for hyperf/database.
v1.0.1
2024-03-20 02:15 UTC
Requires
- php: >=8.1
- ext-swoole: >=5.0
- hyperf/collection: ~3.1.0
- hyperf/database: ~3.1.0
- hyperf/paginator: ^3.1
- hyperf/support: ~3.1.0
- hyperf/tappable: ~3.1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.37
- mockery/mockery: ^1.4.4
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.0.9
This package is auto-updated.
Last update: 2025-02-26 15:35:07 UTC
README
Hyperf-Oracle
Hyperf-Oracle is an Oracle Database Driver package for Hyperf. Extension of Hyperf\Database that uses pdo-oci extension to communicate with Oracle. Through integration of Swoole, Hyperf optimizes resource utilization and boosts concurrency, leading to enhanced throughput and responsiveness when interfacing with Oracle databases.
Quick Installation
composer require jonas-elias/hyperf-oracle
Example
use Hyperf\DbConnection\Db; // select Db::table('users')->get(); // insert Db::table('users')->insert(['name' => 'jonas']); // update Db::table('users')->where('id', '=', 1)->update(['name' => 'johnny']); // delete Db::table('users')->delete(1);
Environment Settings
The following environment variables should be configured to specify the connection details for the Oracle database:
DB_DRIVER=oracle DB_HOST=oracle.host DB_PORT=1521 DB_SERVICE_NAME=XE DB_SID=XE DB_USERNAME=user DB_PASSWORD=password DB_CHARSET=utf8mb4 DB_AUTO_COMMIT=false DB_TIMEZONE=America/Sao_Paulo
Configuration in Code
In your databases.php
configuration file, you can set up the database connection using the following format:
return [ 'default' => [ 'driver' => env('DB_DRIVER', 'oracle'), 'host' => env('DB_HOST', 'host'), 'port' => env('DB_PORT', 1521), 'database' => env('DB_DATABASE', 'hyperf'), 'username' => env('DB_USERNAME', 'oracle'), 'service_name' => env('DB_SERVICE_NAME', 'XE'), 'sid' => env('DB_SID', 'XE'), 'auto_commit' => env('DB_AUTO_COMMIT', false), 'timezone' => env('DB_TIMEZONE', 'America/Sao_Paulo'), 'password' => env('DB_PASSWORD', 'password'), 'charset' => env('DB_CHARSET', 'utf8mb4'), 'prefix' => env('DB_PREFIX', ''), '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' => true, 'inheritance' => 'Model', 'uses' => '', 'table_mapping' => [], ], ], ], ];
Credits
License
The MIT License (MIT). Please see License File for more information.