PHPackages                             ronnievisser/laravel-postgres-ext - 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. ronnievisser/laravel-postgres-ext

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

ronnievisser/laravel-postgres-ext
=================================

Extended PostgreSQL driver for Laravel 5.x

1.2(8y ago)02.3kMITPHPPHP &gt;=5.6

Since Jul 12Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ronnievisser/laravel-postgres-ext)[ Packagist](https://packagist.org/packages/ronnievisser/laravel-postgres-ext)[ RSS](/packages/ronnievisser-laravel-postgres-ext/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

Laravel 5.4 extended PostgreSQL driver
======================================

[](#laravel-54-extended-postgresql-driver)

This is a clone from [yurykabanov/laravel-postgres-ext](https://github.com/yurykabanov/laravel-postgres-ext) and has Laravel 5.4 support.

This project was inspired by features PostgreSQL supports and Laravel does not. Unfortunately, such features are not accepted in official repository (like [this one](https://github.com/laravel/framework/pull/9866)) and developers are told to use raw queries that is completely wrong solution in my opinion.

Requirements
------------

[](#requirements)

1. PHP &gt;= 5.6 or HHVM
2. PostgreSQL. Obviously it has to support particular feature you want to use. For example, to use **views** it has to be at least 9.1, to use **upsert** it has to be at least 9.5 (current stable).

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

[](#installation)

1. Run `composer require ronnievisser/laravel-postgres-ext` to install this package.
2. Change database service provider from original `Illuminate\Database\DatabaseServiceProvider::class` to `RonnieVisser\Database\DatabaseServiceProvider::class`.
3. Models should extend `RonnieVisser\Database\Eloquent\Model` instead of `Illuminate\Database\Eloquent\Model`.

Features available
------------------

[](#features-available)

### UPSERT

[](#upsert)

**UPSERT** (INSERT ON CONFLICT UPDATE) is supported by PostgreSQL since version 9.5 and can be performed by calling

```
Model::upsert($arrayOfAttibutes, $uniqueField)
```

Like original **insert** method, **upsert** can manage multiple records.

### Various index types

[](#various-index-types)

PostgreSQL supports [several index types](https://www.postgresql.org/docs/current/static/sql-createindex.html): **btree**, **hash**, **gist**, **spgist**, **gin**, and **brin** (as for version 9.5) and other index-related features (for example, index can be created concurrently, i.e. without table locking). This package supports creation of all currently supported indexing methods.

Indexes can be created using the same syntax as original one:

```
$table->index('column_name');
```

but it now accepts additional parameters:

```
$table->index('column_name', 'index_name', $methodName, $arrayOfOptions);
```

where `$methodName` is one of methods listed before and `$arrayOfOptions` is array with different options (like concurrency and uniqueness).

**Examples**:

```
// CREATE INDEX CONCURRENTLY ... USING GIST ...
$table->index('column_name', 'index_name', 'gist', [ 'concurrently' => true ]);
// CREATE UNIQUE INDEX ... USING BTREE ...
$table->index('column_name', 'index_name', 'gin',  [ 'unique' => true ]);
```

**Note**, that there's two ways of making column unique: using **constraint** and **index** ([more information](http://stackoverflow.com/questions/23542794/postgres-unique-constraint-vs-index)). Laravel uses **constraint** to make column unique, this behavior stays the same for `$table->unique()` but you can also create **unique index** using `$table->index($col, $index, $method, [ 'unique' => true ])`.

### Views

[](#views)

PostgreSQL supports **views** (since version 9.1) and **materialized views** (since version 9.3). These can be created using `DB::statement()` but it's more convenient to use some aliases to manage them.

Views can be created using following statements:

```
// create non-materialized view using specified select statement
Schema::createView('some_view', 'select 1 as some_value');
// create materialized view using specified select statement
Schema::createView('some_view', 'select 1 as some_value', true);
```

and dropped:

```
// create non-materialized view using specified select statement
Schema::dropView('some_view');
```

So far it doesn't support some query builders since view's select statement could be (and usually *is*) very complicated.

### Jsonb operators

[](#jsonb-operators)

Laravel claims that it *does* support **jsonb** type and jsonb operators like `?`, `?|` and `?&`. But it is impossible to use them in queries since they are treated as parameters in prepared statements. This package automatically wraps these operators in appropriate functions (Note that `?|` also used for other types -- this behavior is not supported at this moment).

### Group by grouping sets, rollup, cube

[](#group-by-grouping-sets-rollup-cube)

Available group by expressions described [in official documentation](https://www.postgresql.org/docs/devel/static/queries-table-expressions.html).

```
// GROUP BY GROUPING SETS ((brand), (size), ())
DB::table('some_table')->groupByGroupingSets('brand', 'size', null);

// GROUP BY ROLLUP (e1, e2, e3)
DB::table('some_table')->groupByRollup('e1', 'e2', 'e3');

// GROUP BY CUBE (e1, e2, e3)
DB::table('some_table')->groupByCube('e1', 'e2', 'e3');
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

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

3

Last Release

3228d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21bf1cce4bbcf3e1252fc7ab50205956a05406e4e80dd7fdb6599abc84c79b59?d=identicon)[Ronster](/maintainers/Ronster)

---

Top Contributors

[![ronnievisser](https://avatars.githubusercontent.com/u/1931199?v=4)](https://github.com/ronnievisser "ronnievisser (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ronnievisser-laravel-postgres-ext/health.svg)

```
[![Health](https://phpackages.com/badges/ronnievisser-laravel-postgres-ext/health.svg)](https://phpackages.com/packages/ronnievisser-laravel-postgres-ext)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[abbasudo/laravel-purity

elegant way to add filter and sort in laravel

514330.5k1](/packages/abbasudo-laravel-purity)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

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