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

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

yawaweb/yii2-oci8
=================

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

1.0(2y ago)0128↓66.7%MITPHPPHP ^8.0

Since Apr 22Pushed 2y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Yii2-Oci8 for PHP 8+
====================

[](#yii2-oci8-for-php-8)

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

**Requirements**

- Yii ^2.x;
- yajra/pdo-via-oci8: ^3;
- PHP ^8.0.

**Installation**

```
composer require yawaweb/yii2-oci8

```

**Yii2 configuration example for an Oracle database**

Yii2 configuration:

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

Database configuration in `db.php`:

```
return [
    'class' => 'yawaweb\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`:

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

    //Defining a cache schema component
    'cachedSchema' => [
        'class' => 'yawaweb\yii2oci8\CachedSchema',
        // Optional, dafault is 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) {
            //Cache everything 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 \yawaweb\yii2oci8\CachedSchema */
        $schema = $event->sender->getSchema();

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

750d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/277d39864b49e12c5941a05cd0e267246e70b2bebf1e2a413c4e29116c17f281?d=identicon)[yawaweb](/maintainers/yawaweb)

---

Top Contributors

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

---

Tags

databaseoracleoci8yii2

### Embed Badge

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

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8703.0M17](/packages/yajra-laravel-oci8)[dmstr/yii2-db

Database extensions

19618.8k6](/packages/dmstr-yii2-db)[jpina/oci8

Oracle database wrapper for PHP oci8 functions

1713.9k](/packages/jpina-oci8)[spanjeta/yii2-backup

Database Backup and Restore functionality

285.0k1](/packages/spanjeta-yii2-backup)[jonas-elias/hyperf-oracle

A oracle handler for hyperf/database.

102.0k](/packages/jonas-elias-hyperf-oracle)

PHPackages © 2026

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