PHPackages                             aliobeidat/yii2-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. aliobeidat/yii2-oci8

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

aliobeidat/yii2-oci8
====================

Yii2 extension which uses well written pdo-via-oci8 package for standard PHP Oracle functions (OCI8)

017PHP

Since Nov 29Pushed 3y ago1 watchersCompare

[ Source](https://github.com/AliObeidat/yii2-oci8)[ Packagist](https://packagist.org/packages/aliobeidat/yii2-oci8)[ RSS](/packages/aliobeidat-yii2-oci8/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

yii2-oci8
=========

[](#yii2-oci8)

Yii2 OCI8 extension which uses [yajra/pdo-via-oci8](https://github.com/yajra/pdo-via-oci8) library with optional full table schema caching. Supported PHP8.

**Supported**

- Yii 2.x;
- yajra/pdo-via-oci8 3.x;
- &gt;= PHP 8.1

**Installation**

Add to your `composer.json` file:

```
   "require": {
     "aliobeidat/yii2-oci8": "dev-master"
   }

```

And then run `composer update`.

**Yii2 configuration example for an Oracle database**

Yii2 configuration:

```
$config = [
    ...
    'components' => [
        ...
        'db' => require(__DIR__ . '/db.php'),
        ...
    ]
];
```

Database configuration in `db.php`:

```
return [
    'class' => 'aliobeidat\yii2oci8\Oci8Connection',
    'dsn' => 'oci:dbname=//192.168.0.1:1521/db.local;charset=AL32UTF8;',
    'username' => 'user',
    'password' => 'pass',
    'attributes' => [ PDO::ATTR_PERSISTENT => true ],
    'enableSchemaCache' => true, //Oracle dictionaries is too slow :(, enable caching
    'schemaCacheDuration' => 60 * 60, //1 hour
    'on afterOpen' => function($event) {

    /* A session configuration example */
        $q = execute();
    }
];
```

**Example**

Feel free to use Yii2 `ActiveRecord` methods:

```
$cars = Car::find()->where(['YEAR' => '1939'])->indexBy('ID')->all();
```

Getting a raw database handler and working with it:

```
$dbh = Yii::$app->db->getDbh();
$stmt = oci_parse($dbh, "select * from DEPARTMENTS where NAME = :name");
$name = 'NYPD';
oci_bind_by_name($stmt, ':name', $name);
oci_execute($stmt);
...
//fetching result
```

**Caching features**

To enable caching for all tables in a schema add lines below in a database connection configuration `db.php` or `main.php`:

```
    ...
    //Disabling Yii2 schema caching
    'enableSchemaCache' => false

    //Defining a cache schema component
    'cachedSchema' => [
        'class' => 'aliobeidat\yii2oci8\CachedSchema',
        // Optional, default is the current connection schema.
        'cachingSchemas' => ['HR', 'SCOTT'],
        // Optional. This callback must return `true` for a table name if it need to be cached.
        'tableNameFilter' => function ($tableName, $schemaName) {
            //Cache everythings but the EMP table from HR and SCOTT schemas
            return $tableName != 'EMP';
        }
    ],
    ...
```

Table schemas saves to the default Yii2 cache component. To build schema cache after a connection opens:

```
    'on afterOpen' => function($event)
    {
        $event->sender->createCommand($q)->execute();

        /* @var $schema \aliobeidat\yii2oci8\CachedSchema */
        $schema = $event->sender->getSchema();

        if (!$schema->isCached)
            //Rebuild schema cache
            $schema->buildSchemaCache();
    },
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b700e42529c3906d7fb2b1e232825eb2273f7388af8adc3ad9713cfdb518a0df?d=identicon)[AliObeidat](/maintainers/AliObeidat)

---

Top Contributors

[![AliObeidat](https://avatars.githubusercontent.com/u/29369893?v=4)](https://github.com/AliObeidat "AliObeidat (2 commits)")

### Embed Badge

![Health badge](/badges/aliobeidat-yii2-oci8/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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