PHPackages                             yajra/laravel-oci8 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. yajra/laravel-oci8

ActiveLibrary[Database &amp; ORM](/categories/database)

yajra/laravel-oci8
==================

Oracle DB driver for Laravel via OCI8

v13.7.0(2w ago)8793.2M↓35.3%249[7 issues](https://github.com/yajra/laravel-oci8/issues)[8 PRs](https://github.com/yajra/laravel-oci8/pulls)18MITPHPPHP ^8.3CI passing

Since Jan 15Pushed 1w ago29 watchersCompare

[ Source](https://github.com/yajra/laravel-oci8)[ Packagist](https://packagist.org/packages/yajra/laravel-oci8)[ Fund](https://www.paypal.me/yajra)[ GitHub Sponsors](https://github.com/yajra)[ RSS](/packages/yajra-laravel-oci8/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (55)Versions (373)Used By (18)

Oracle DB driver for Laravel via OCI8
=====================================

[](#oracle-db-driver-for-laravel-via-oci8)

[![Continuous Integration](https://github.com/yajra/laravel-oci8/actions/workflows/continuous-integration.yml/badge.svg?branch=master)](https://github.com/yajra/laravel-oci8/actions/workflows/continuous-integration.yml?query=branch%3Amaster)[![Static Analysis](https://github.com/yajra/laravel-oci8/actions/workflows/static-analysis.yml/badge.svg?branch=master)](https://github.com/yajra/laravel-oci8/actions/workflows/static-analysis.yml?query=branch%3Amaster)[![Coverage](https://raw.githubusercontent.com/yajra/laravel-oci8/coverage-report/badges/coverage.svg)](https://github.com/yajra/laravel-oci8/actions/workflows/continuous-integration.yml?query=branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/15c34a8d821e05fc9e12c5a707412bf6b00c696020bf540929f0e1d4f7e3a42d/68747470733a2f2f706f7365722e707567782e6f72672f79616a72612f6c61726176656c2d6f6369382f642f746f74616c2e737667)](https://packagist.org/packages/yajra/laravel-oci8)[![Latest Stable Version](https://camo.githubusercontent.com/52aa0351cf9a08e178356ae1734f0dfe179b854530fc6490930a13375e800935/68747470733a2f2f706f7365722e707567782e6f72672f79616a72612f6c61726176656c2d6f6369382f762f737461626c652e737667)](https://packagist.org/packages/yajra/laravel-oci8)[![License](https://camo.githubusercontent.com/b0638f84f86a85b8703803f5e66fca5a99f32dd3b02dd3950115b5014a52f111/68747470733a2f2f706f7365722e707567782e6f72672f79616a72612f6c61726176656c2d6f6369382f6c6963656e73652e737667)](https://packagist.org/packages/yajra/laravel-oci8)

Laravel-OCI8
------------

[](#laravel-oci8)

Laravel-OCI8 is an Oracle Database Driver package for [Laravel](http://laravel.com/). Laravel-OCI8 is an extension of [Illuminate/Database](https://github.com/illuminate/database) that uses [OCI8](http://php.net/oci8) extension to communicate with Oracle. Thanks to @taylorotwell.

Documentations
--------------

[](#documentations)

- You will find user-friendly and updated documentation here: [Laravel-OCI8 Docs](https://yajrabox.com/docs/laravel-oci8)
- All about oracle and php:[The Underground PHP and Oracle Manual](http://www.oracle.com/technetwork/database/database-technologies/php/201212-ug-php-oracle-1884760.pdf)

Laravel Version Compatibility
-----------------------------

[](#laravel-version-compatibility)

LaravelPackage5.1.x5.1.x5.2.x5.2.x5.3.x5.3.x5.4.x5.4.x5.5.x5.5.x5.6.x5.6.x5.7.x5.7.x5.8.x5.8.x6.x6.x7.x7.x8.x8.x9.x9.x10.x10.x11.x11.x12.x12.x13.x13.xQuick Installation
------------------

[](#quick-installation)

```
composer require yajra/laravel-oci8:^13
```

Larastan / PHPStan
------------------

[](#larastan--phpstan)

This package includes an optional PHPStan/Larastan extension for OCI8-specific `DB` methods. Include it in your `phpstan.neon` if you want those methods recognized during static analysis.

```
includes:
    - vendor/yajra/laravel-oci8/extension.neon
```

Service Provider (Optional on Laravel 5.5+)
-------------------------------------------

[](#service-provider-optional-on-laravel-55)

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)
------------------------

[](#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](http://lumen.laravel.com/docs/configuration#configuration-files), 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'),
    'connect_timeout' => env('DB_CONNECT_TIMEOUT', ''),
    'retry_count'    => env('DB_RETRY_COUNT', '3'), // 12c and above only
    'retry_delay'    => env('DB_RETRY_DELAY', '1'), // 12c and above only
    'transport_connect_timeout' => env('DB_TRANSPORT_CONNECT_TIMEOUT', '60'), // 12c and above only
    'expire_time'    => env('DB_EXPIRE_TIME', '0'), // 19c and above only
    '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
DB_CONNECT_TIMEOUT=10
DB_RETRY_COUNT=3
DB_RETRY_DELAY=1
DB_TRANSPORT_CONNECT_TIMEOUT=60
DB_EXPIRE_TIME=0
```

> 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 versions
---------------

[](#oracle-versions)

To set this version use `DB_SERVER_VERSION` env variable or change `server_version` variable in the oracle.php config.

### 11g

[](#11g)

This is the baseline, if no version is set, this version is assumed.

### 12c

[](#12c)

- Use fetch/offset where possible instead of rownumber.
- Use identity instead of seqvence/trigger for ids when using laravel's scheme builder. ([\#944](https://github.com/yajra/laravel-oci8/pull/944))
- JoinLateral support ([\#989](https://github.com/yajra/laravel-oci8/pull/989))

### 12cR2

[](#12cr2)

- In whereLike use `binary ci` for case insensitivity. ([\#945](https://github.com/yajra/laravel-oci8/pull/945))

### 19c

[](#19c)

- JSON path updates with query builder `update(['options->path' => $value])`. ([\#1007](https://github.com/yajra/laravel-oci8/pull/1007))

### 21c

[](#21c)

- Use native json type instead of clob in schema builder. ([\#983](https://github.com/yajra/laravel-oci8/pull/983))

Oracle Max Name Length
----------------------

[](#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
--------------------------------------

[](#laravel-52-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,
    ],
]
```

JSON support
------------

[](#json-support)

Laravel-OCI8 provides JSON query support for Oracle databases.

> ⚠️This requires Oracle 12c02 or higher.

JSON path updates using Laravel's `update(['json->key' => ...])` syntax are supported on Oracle 19c or higher:

```
DB::table('users')
    ->where('id', $id)
    ->update(['options->profile->settings->theme' => 'dark']);
```

Only one JSON path may be updated for the same JSON column in a single `update()` call. Use separate `update()` calls for multiple paths, matching Laravel's PostgreSQL and MariaDB grammar behavior.

On Oracle versions below 19c, JSON path updates are not supported. Modify the full JSON document in the application and save the column value instead.

Credits
-------

[](#credits)

- [Arjay Angeles](https://github.com/yajra)
- [Jimmy Felder](https://github.com/jfelder/Laravel-OracleDB)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

81

—

ExcellentBetter than 100% of packages

Maintenance97

Actively maintained with recent releases

Popularity68

Solid adoption and visibility

Community45

Growing community involvement

Maturity98

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 81.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Total

368

Last Release

20d ago

Major Versions

v11.6.4 → v12.0.02025-02-28

v11.6.5 → v12.1.62025-09-06

v11.6.6 → v12.1.82025-09-18

v11.6.7 → v12.2.02025-12-08

12.x-dev → v13.0.02026-03-18

PHP version history (15 changes)0.1.0PHP &gt;=5.3.0

v2.0.0.betaPHP &gt;=5.4.0

v2.0.0PHP &gt;=5.4

v3.0.0PHP &gt;=5.5.9

v5.3.0PHP &gt;=5.6.4

v5.5.0PHP &gt;=7.0.0

v5.6.0PHP ^7.1.3

v6.0.0PHP ^7.2

v7.0.0PHP ^7.2.5

v8.0.0PHP ^7.3

v8.3.0PHP ^7.3|^8.0

v9.0.0PHP ^8.0.2

v10.0.0PHP ^8.1

v11.0.0PHP ^8.2

v13.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c245d1effe6022f9f09b2e8b9cce26743de03a64d612cea4ce9885560d7c0b2?d=identicon)[yajra](/maintainers/yajra)

---

Top Contributors

[![yajra](https://avatars.githubusercontent.com/u/2687997?v=4)](https://github.com/yajra "yajra (1159 commits)")[![csaba215](https://avatars.githubusercontent.com/u/11250204?v=4)](https://github.com/csaba215 "csaba215 (74 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (26 commits)")[![jonas-elias](https://avatars.githubusercontent.com/u/48037643?v=4)](https://github.com/jonas-elias "jonas-elias (21 commits)")[![ZsgsDesign](https://avatars.githubusercontent.com/u/19504567?v=4)](https://github.com/ZsgsDesign "ZsgsDesign (17 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (11 commits)")[![forgandenny](https://avatars.githubusercontent.com/u/2554234?v=4)](https://github.com/forgandenny "forgandenny (10 commits)")[![ChaosPower](https://avatars.githubusercontent.com/u/260845?v=4)](https://github.com/ChaosPower "ChaosPower (9 commits)")[![mfrancoisbbs](https://avatars.githubusercontent.com/u/133215273?v=4)](https://github.com/mfrancoisbbs "mfrancoisbbs (9 commits)")[![ErDiabIo](https://avatars.githubusercontent.com/u/35238519?v=4)](https://github.com/ErDiabIo "ErDiabIo (9 commits)")[![joaorobertopb](https://avatars.githubusercontent.com/u/6556083?v=4)](https://github.com/joaorobertopb "joaorobertopb (9 commits)")[![masoudtajer](https://avatars.githubusercontent.com/u/49834756?v=4)](https://github.com/masoudtajer "masoudtajer (8 commits)")[![Xinguang](https://avatars.githubusercontent.com/u/2002838?v=4)](https://github.com/Xinguang "Xinguang (7 commits)")[![Adam2Marsh](https://avatars.githubusercontent.com/u/7213334?v=4)](https://github.com/Adam2Marsh "Adam2Marsh (6 commits)")[![jidago](https://avatars.githubusercontent.com/u/56063120?v=4)](https://github.com/jidago "jidago (6 commits)")[![hpacleb](https://avatars.githubusercontent.com/u/24486552?v=4)](https://github.com/hpacleb "hpacleb (5 commits)")[![MohammadMehrabani](https://avatars.githubusercontent.com/u/18621426?v=4)](https://github.com/MohammadMehrabani "MohammadMehrabani (5 commits)")[![wremon-yo](https://avatars.githubusercontent.com/u/174759679?v=4)](https://github.com/wremon-yo "wremon-yo (4 commits)")[![jfelder](https://avatars.githubusercontent.com/u/4504343?v=4)](https://github.com/jfelder "jfelder (4 commits)")[![mstaack](https://avatars.githubusercontent.com/u/10169509?v=4)](https://github.com/mstaack "mstaack (4 commits)")

---

Tags

hacktoberfestlaravellaravel-oci8oci8oraclephplaraveloracleoci8yajrapdo\_oci

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/yajra-laravel-oci8/health.svg)

```
[![Health](https://phpackages.com/badges/yajra-laravel-oci8/health.svg)](https://phpackages.com/packages/yajra-laravel-oci8)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[api-platform/laravel

API Platform support for Laravel

58171.8k14](/packages/api-platform-laravel)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
