PHPackages                             i-excellent/yii2-pgsql-schema - 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. i-excellent/yii2-pgsql-schema

ActiveYii2-extension[Database &amp; ORM](/categories/database)

i-excellent/yii2-pgsql-schema
=============================

PostgreSQL schemas for Yii2, with fields jsonb, json

1.0.2(8y ago)128MITPHP

Since Dec 17Pushed 8y ago1 watchersCompare

[ Source](https://github.com/i-excellent/yii2-pgsql-schema)[ Packagist](https://packagist.org/packages/i-excellent/yii2-pgsql-schema)[ RSS](/packages/i-excellent-yii2-pgsql-schema/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

yii2-pgsql
==========

[](#yii2-pgsql)

Improved PostgreSQL schemas for Yii2.

Supports follow types for ActiveRecord models:

[![Latest Stable Version](https://camo.githubusercontent.com/0e0f4771a01c3f8fe86693c5be644a51bc5a4a74bc084fc9beb8ce318e6af853/68747470733a2f2f706f7365722e707567782e6f72672f692d657863656c6c656e742f796969322d706773716c2d736368656d612f762f737461626c65)](https://packagist.org/packages/i-excellent/yii2-pgsql-schema)[![License](https://camo.githubusercontent.com/4c3283e96d3703b322e53450e8b2192d7f7e501c723f2d0cd485e41c4e3a05cd/68747470733a2f2f706f7365722e707567782e6f72672f692d657863656c6c656e742f796969322d706773716c2d736368656d612f6c6963656e7365)](https://packagist.org/packages/i-excellent/yii2-pgsql-schema)

Limitation
----------

[](#limitation)

When you use this extension you can't specify the PDO type by using an array: `[value, type]`,

e.g. `['name' => 'John', 'profile' => [$profile, \PDO::PARAM_LOB]]`.

See the issue [\#7481](https://github.com/yiisoft/yii2/issues/7481)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist i-excellent/yii2-pgsql-schema

```

or add

```
"i-excellent/yii2-pgsql-schema": "~1.0"

```

to the require section of your `composer.json` file.

Configuration
-------------

[](#configuration)

Once the extension is installed, add following code to your application configuration:

```
return [
    //...
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'pgsql:host=localhost;dbname=',
            'username' => 'postgres',
            'password' => '',
            'schemaMap' => [
                'pgsql'=> 'excellent\pgsql\Schema',
            ],
        ],
    ],
];
```

Configure Model's rules

```
/**
 * @property string[] $attribute1 array of string
 * @property array $attribute2 associative array or just array
 * @property integer|string|\DateTime $attribute3 for more information about the type see \Yii::$app->formatter->asDatetime()
 */
class Model extends ActiveRecord
{
    //...
    public function rules()
    {
        return [
            [['attribute1'], 'each', 'rule' => ['string']],
            [['attribute2'], 'safe'],
        ];
    }
}
```

Usage
-----

[](#usage)

You can then save array, json and timestamp types in database as follows:

```
/**
 * @var ActiveRecord $model
 */
$model->attribute1 = ['some', 'values', 'of', 'array'];
$model->attribute2 = ['some' => 'values', 'of' => 'array'];
$model->save();
```

and then use them in your code

```
/**
 * @var ActiveRecord $model
 */
$model = Model::findOne($pk);
$model->attribute1; // is array
$model->attribute2; // is associative array (decoded json)
```

[Composite types](docs/composite.md)

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Every ~0 days

Total

2

Last Release

3116d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17882552?v=4)[i-excellent](/maintainers/i-excellent)[@i-excellent](https://github.com/i-excellent)

---

Top Contributors

[![popov-do](https://avatars.githubusercontent.com/u/17734367?v=4)](https://github.com/popov-do "popov-do (9 commits)")

---

Tags

extensionjsonbpostgresqlpostgresql-databaseschemayii2jsonarraypostgresqlpostgrespgsqldatetimeyii2extensiontimestampbit

### Embed Badge

![Health badge](/badges/i-excellent-yii2-pgsql-schema/health.svg)

```
[![Health](https://phpackages.com/badges/i-excellent-yii2-pgsql-schema/health.svg)](https://phpackages.com/packages/i-excellent-yii2-pgsql-schema)
```

###  Alternatives

[tigrov/yii2-pgsql

Improved PostgreSQL schemas for Yii2

3469.3k](/packages/tigrov-yii2-pgsql)[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4535.7M4](/packages/martin-georgiev-postgresql-for-doctrine)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58825.2M48](/packages/scienta-doctrine-json-functions)[aura/sql

A PDO extension that provides lazy connections, array quoting, query profiling, value binding, and convenience methods for common fetch styles. Because it extends PDO, existing code that uses PDO can use this without any changes to the existing code.

5642.6M53](/packages/aura-sql)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4563.1M37](/packages/aura-sqlquery)[nanson/yii2-postgis

Yii2-extension to work with postgis data

1852.9k](/packages/nanson-yii2-postgis)

PHPackages © 2026

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