yajra / laravel-oci8
Oracle DB driver for Laravel via OCI8
Fund package maintenance!
yajra
Patreon
www.paypal.me/yajra
Installs: 2 067 698
Dependents: 18
Suggesters: 6
Security: 0
Stars: 834
Watchers: 29
Forks: 237
Open Issues: 21
Requires
- php: ^8.2
- ext-oci8: >=3.0.1
- ext-pdo: *
- illuminate/database: ^11.15.0
- illuminate/pagination: ^11.15.0
- illuminate/support: ^11.15.0
- illuminate/validation: ^11.15.0
- yajra/laravel-pdo-via-oci8: ^3.4.4
Requires (Dev)
- mockery/mockery: ^1.6.12
- orchestra/testbench: ^9.1.2
- phpunit/phpunit: ^10.5|^11.2.7
- dev-master / 11.x-dev
- v11.6.2
- v11.6.1
- v11.6.0
- v11.5.1
- v11.5.0
- v11.4.1
- v11.4.0
- v11.3.0
- v11.2.5
- v11.2.4
- v11.2.3
- v11.2.2
- v11.2.1
- v11.2.0
- v11.1.0
- v11.0.0
- 10.x-dev
- v10.6.0
- v10.5.3
- v10.5.2
- v10.5.1
- v10.5.0
- v10.4.4
- v10.4.3
- v10.4.2
- v10.4.1
- v10.4.0
- v10.3.4
- v10.3.3
- v10.3.2
- v10.3.1
- v10.3.0
- v10.2.0
- v10.1.0
- v10.0.0
- 9.x-dev
- v9.5.4
- v9.5.3
- v9.5.2
- v9.5.1
- v9.5.0
- v9.4.0
- v9.3.1
- v9.3.0
- v9.2.1
- v9.2.0
- v9.1.0
- v9.0.4
- v9.0.3
- v9.0.2
- v9.0.1
- v9.0.0
- 8.x-dev
- v8.8.0
- v8.7.0
- v8.6.3
- v8.6.2
- v8.6.1
- v8.6.0
- v8.5.0
- v8.4.1
- v8.4.0
- v8.3.0
- v8.2.3
- v8.2.2
- v8.2.1
- v8.2.0
- v8.1.3
- v8.1.2
- v8.1.1
- v8.1.0
- v8.0.1
- v8.0.0
- 7.x-dev
- v7.1.1
- v7.1.0
- v7.0.2
- v7.0.1
- v7.0.0
- 6.x-dev
- v6.1.3
- v6.1.2
- v6.1.1
- v6.1.0
- v6.0.4
- v6.0.3
- v6.0.2
- v6.0.1
- v6.0.0
- 5.8.x-dev
- v5.8.4
- v5.8.3
- v5.8.2
- v5.8.1
- v5.8.0
- 5.7.x-dev
- v5.7.4
- v5.7.3
- v5.7.2
- v5.7.1
- v5.7.0
- 5.6.x-dev
- v5.6.5
- v5.6.4
- v5.6.3
- v5.6.2
- v5.6.1
- v5.6.0
- 5.5.x-dev
- v5.5.9
- v5.5.8
- v5.5.7
- v5.5.6
- v5.5.5
- v5.5.4
- v5.5.3
- v5.5.2
- v5.5.1
- v5.5.0
- 5.4.x-dev
- v5.4.21
- v5.4.20
- v5.4.19
- v5.4.18
- v5.4.17
- v5.4.16
- v5.4.15
- v5.4.14
- v5.4.13
- v5.4.12
- v5.4.11
- v5.4.10
- v5.4.9
- v5.4.8
- v5.4.7
- v5.4.6
- v5.4.5
- v5.4.4
- v5.4.3
- v5.4.2
- v5.4.1
- v5.4.0
- 5.3.x-dev
- v5.3.9
- v5.3.8
- v5.3.7
- v5.3.6
- v5.3.5
- v5.3.4
- v5.3.3
- v5.3.2
- v5.3.1
- v5.3.0
- 5.2.x-dev
- v5.2.14
- v5.2.13
- v5.2.12
- v5.2.11
- v5.2.10
- v5.2.9
- v5.2.8
- v5.2.7
- v5.2.6
- v5.2.5
- v5.2.4
- v5.2.3
- v5.2.2
- v5.2.1
- v5.2.0
- 5.1.x-dev
- v5.1.4
- v5.1.3
- v5.1.2
- v5.1.1
- v5.1.0
- v4.2.6
- v4.2.5
- v4.2.4
- v4.2.3
- v4.2.2
- v4.2.1
- v4.1.2
- v4.1.1
- v4.1.0
- 4.0.x-dev
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0.0
- v4.0.0-RC1.1
- v4.0.0-RC1
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- 3.0.x-dev
- v3.0.0
- 2.4.x-dev
- v2.4.10
- v2.4.9
- v2.4.8
- v2.4.7
- v2.4.6
- v2.4.5
- v2.4.4
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.1
- v2.3.0
- v2.2.0
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4.2
- v2.1.4.1
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v2.0.0.beta
- 1.15.x-dev
- v1.15.0
- v1.14.1
- v1.14.0
- v1.13.0
- v1.12.0
- v1.11.0
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.0
- v1.8.0
- v1.7.0
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.12
- v1.5.11
- v1.5.10
- v1.5.9
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.1
- 1.1.0
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.3.0
- 0.2.29
- 0.2.28
- 0.2.27
- 0.2.26
- 0.2.25
- 0.2.24
- 0.2.23
- 0.2.22
- 0.2.21
- 0.2.20
- 0.2.19
- 0.2.18
- 0.2.17
- 0.2.16
- 0.2.15
- 0.2.14
- 0.2.13
- 0.2.12
- 0.2.11
- 0.2.10
- 0.2.9
- 0.2.8
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-pr/878
- dev-fix-ci-unique-index
- dev-analysis-0gN4Lm
- dev-phpstan
This package is auto-updated.
Last update: 2024-11-10 05:51:11 UTC
README
Laravel-OCI8
Laravel-OCI8 is an Oracle Database Driver package for Laravel. Laravel-OCI8 is an extension of Illuminate/Database that uses OCI8 extension to communicate with Oracle. Thanks to @taylorotwell.
Documentations
- You will find user-friendly and updated documentation here: Laravel-OCI8 Docs
- All about oracle and php:The Underground PHP and Oracle Manual
Laravel Version Compatibility
Quick Installation
composer require yajra/laravel-oci8:^11
Service Provider (Optional on Laravel 5.5+)
Once Composer has installed or updated your packages you need to register Laravel-OCI8. Open up config/app.php
and find the providers key and add:
Yajra\Oci8\Oci8ServiceProvider::class,
Configuration (OPTIONAL)
Finally you can optionally publish a configuration file by running the following Artisan command.
If config file is not publish, the package will automatically use what is declared on your .env
file database configuration.
php artisan vendor:publish --tag=oracle
This will copy the configuration file to config/oracle.php
.
Note: For Laravel Lumen configuration, make sure you have a
config/database.php
file on your project and append the configuration below:
'oracle' => [ 'driver' => 'oracle', 'tns' => env('DB_TNS', ''), 'host' => env('DB_HOST', ''), 'port' => env('DB_PORT', '1521'), 'database' => env('DB_DATABASE', ''), 'service_name' => env('DB_SERVICE_NAME', ''), 'username' => env('DB_USERNAME', ''), 'password' => env('DB_PASSWORD', ''), 'charset' => env('DB_CHARSET', 'AL32UTF8'), 'prefix' => env('DB_PREFIX', ''), 'prefix_schema' => env('DB_SCHEMA_PREFIX', ''), 'edition' => env('DB_EDITION', 'ora$base'), 'server_version' => env('DB_SERVER_VERSION', '11g'), 'load_balance' => env('DB_LOAD_BALANCE', 'yes'), 'dynamic' => [], 'max_name_len' => env('ORA_MAX_NAME_LEN', 30), ],
Then, you can set connection data in your
.env
files:
DB_CONNECTION=oracle DB_HOST=oracle.host DB_PORT=1521 DB_SERVICE_NAME=orcl DB_DATABASE=xe DB_USERNAME=hr DB_PASSWORD=hr
If you want to connect to a cluster containing multiple hosts, you can either set
tns
manually or set host as a comma-separated array and configure other fields as you wish:
DB_CONNECTION=oracle DB_HOST=oracle1.host, oracle2.host DB_PORT=1521 DB_SERVICE_NAME=orcl DB_LOAD_BALANCE=no DB_DATABASE=xe DB_USERNAME=hr DB_PASSWORD=hr
If you need to connect with the service name instead of tns, you can use the configuration below:
'oracle' => [ 'driver' => 'oracle', 'host' => 'oracle.host', 'port' => '1521', 'database' => 'xe', 'service_name' => 'sid_alias', 'username' => 'hr', 'password' => 'hr', 'charset' => '', 'prefix' => '', ]
In some cases you may wish to set the connection parameters dynamically in your app. For instance, you may access more than one database, or your users may already have their own accounts on the Oracle database:
'oracle' => [ 'driver' => 'oracle', 'host' => 'oracle.host', 'port' => '1521', 'service_name' => 'sid_alias', 'prefix' => 'schemaowner', 'dynamic' => [App\Models\Oracle\Config::class, 'dynamicConfig'], ]
The callback function in your app must be static and accept a reference to the $config[]
array (which will already be populated with values set in the config file):
namespace App\Models\Oracle; class Config { public static function dynamicConfig(&$config) { if (Illuminate\Support\Facades\Auth::check()) { $config['username'] = App\Oracle\Config::getOraUser(); $config['password'] = App\Oracle\Config::getOraPass(); } } }
Then run your laravel installation...
Oracle Max Name Length
By default, DB object name are limited to 30 characters. To increase the limit, you can set the ORA_MAX_NAME_LEN=128
in your .env
file.
Note: this config requires Oracle 12c02 or higher.
[Laravel 5.2++] Oracle User Provider
When using oracle, we may encounter a problem on authentication because oracle queries are case sensitive by default. By using this oracle user provider, we will now be able to avoid user issues when logging in and doing a forgot password failure because of case sensitive search.
To use, just update auth.php
config and set the driver to oracle
'providers' => [ 'users' => [ 'driver' => 'oracle', 'model' => App\User::class, ], ]
Credits
License
The MIT License (MIT). Please see License File for more information.