PHPackages                             dgarbs51/postgres-pooled-mode - 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. dgarbs51/postgres-pooled-mode

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

dgarbs51/postgres-pooled-mode
=============================

Drop-in Laravel support for PostgreSQL transaction poolers with direct connections for schema operations.

v0.0.2(3d ago)07↑2471.4%MITPHPPHP ^8.2CI passing

Since Jun 7Pushed 3d agoCompare

[ Source](https://github.com/DGarbs51/postgres-pooled-mode)[ Packagist](https://packagist.org/packages/dgarbs51/postgres-pooled-mode)[ RSS](/packages/dgarbs51-postgres-pooled-mode/feed)WikiDiscussions main Synced 2d ago

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

Postgres Pooled Mode for Laravel
================================

[](#postgres-pooled-mode-for-laravel)

[![Tests](https://github.com/DGarbs51/postgres-pooled-mode/actions/workflows/tests.yml/badge.svg)](https://github.com/DGarbs51/postgres-pooled-mode/actions/workflows/tests.yml)[![PHP Version](https://camo.githubusercontent.com/dfdb7ba444e58ba3de2a310acdc9b8b403441a256f3cfd1280c781cb24c106da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64676172627335312f706f7374677265732d706f6f6c65642d6d6f64652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dgarbs51/postgres-pooled-mode)[![License](https://camo.githubusercontent.com/28a344eaf379c71b24c4e02f3dc2e1d3fe3c317284f51156f594535ead82b080/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64676172627335312f706f7374677265732d706f6f6c65642d6d6f64652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dgarbs51/postgres-pooled-mode)

Drop-in Laravel support for PostgreSQL transaction poolers such as PgBouncer, Neon pooled connections, PlanetScale pooled connections, and AWS RDS Proxy.

The package keeps normal application traffic on the pooled endpoint while giving schema and maintenance workflows a direct PostgreSQL endpoint for operations that do not work reliably through transaction pooling.

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

[](#installation)

```
composer require dgarbs51/postgres-pooled-mode
```

The service provider is auto-discovered by Laravel.

You may publish the package config:

```
php artisan vendor:publish --tag=postgres-pooled-mode-config
```

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

[](#configuration)

Add `pooled` and `direct` keys to your PostgreSQL connection:

```
'pgsql' => [
    'driver' => 'pgsql',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '5432'),
    'database' => env('DB_DATABASE', 'laravel'),
    'username' => env('DB_USERNAME', 'root'),
    'password' => env('DB_PASSWORD', ''),
    'charset' => env('DB_CHARSET', 'utf8'),
    'prefix' => '',
    'prefix_indexes' => true,
    'search_path' => 'public',
    'sslmode' => env('DB_SSLMODE', 'prefer'),

    'pooled' => env('DB_POOLED', false),
    'direct' => array_filter([
        'host' => env('DB_DIRECT_HOST'),
        'port' => env('DB_DIRECT_PORT'),
        'username' => env('DB_DIRECT_USERNAME'),
        'password' => env('DB_DIRECT_PASSWORD'),
        'sslmode' => env('DB_DIRECT_SSLMODE'),
    ]),
],
```

Then set the pooler and direct endpoints:

```
DB_CONNECTION=pgsql
DB_HOST=your-pooler-host
DB_PORT=6432
DB_POOLED=true

DB_DIRECT_HOST=your-direct-host
DB_DIRECT_PORT=5432
DB_DIRECT_USERNAME=your-direct-username
DB_DIRECT_PASSWORD=your-direct-password
DB_DIRECT_SSLMODE=require
```

If your pooler uses the same host but differentiates pooled and direct connections by port and username, leave `DB_DIRECT_HOST` unset and provide only the direct port and username.

What It Does
------------

[](#what-it-does)

- Enables PDO emulated prepares for pooled PostgreSQL connections unless the option is explicitly configured.
- Keeps direct PostgreSQL connections on native prepares unless the direct config explicitly opts into emulated prepares.
- Adds `connection::direct` routing through the package database manager.
- Routes migrations to `connection::direct` when a direct endpoint is configured.
- Uses the direct endpoint for PostgreSQL schema dump/load.
- Routes `db:wipe`, `db:show`, and `db:table` through direct when appropriate.
- Adds `php artisan db --pooled`; without `--pooled`, `php artisan db` defaults to direct only when the raw connection config has `pooled => true`.
- Converts PHP boolean bindings to PostgreSQL-compatible `'true'` / `'false'`strings when PDO emulated prepares are active.

Boolean Bindings
----------------

[](#boolean-bindings)

When PDO emulated prepares are active, PostgreSQL receives the query with values interpolated on the client side. For boolean columns, bind PHP booleans:

```
User::where('active', true)->get();
```

Avoid integer boolean values under pooled emulated prepares:

```
User::where('active', 1)->get();
```

Laravel cannot infer column types from an arbitrary integer binding, so `1`remains an integer literal.

Disabling Behavior
------------------

[](#disabling-behavior)

```
POSTGRES_POOLED_MODE_ENABLED=false
POSTGRES_POOLED_MODE_REPLACE_COMMANDS=false
POSTGRES_POOLED_MODE_MIGRATIONS_USE_DIRECT=false
```

Testing
-------

[](#testing)

```
composer test
composer format
```

License
-------

[](#license)

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

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance99

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/58236685?v=4)[Devon Garbalosa](/maintainers/DGarbs51)[@DGarbs51](https://github.com/DGarbs51)

---

Top Contributors

[![DGarbs51](https://avatars.githubusercontent.com/u/58236685?v=4)](https://github.com/DGarbs51 "DGarbs51 (3 commits)")

---

Tags

laravelpostgresqlpostgrespgbouncerconnection-poolingrds-proxy

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/dgarbs51-postgres-pooled-mode/health.svg)

```
[![Health](https://phpackages.com/badges/dgarbs51-postgres-pooled-mode/health.svg)](https://phpackages.com/packages/dgarbs51-postgres-pooled-mode)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.4k](/packages/larastan-larastan)[spatie/laravel-medialibrary

Associate files with Eloquent models

6.1k41.3M594](/packages/spatie-laravel-medialibrary)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

436834.4k1](/packages/clickbar-laravel-magellan)[itpathsolutions/dbstan

Database Standardization and Analysis Tool for Laravel

442.1k](/packages/itpathsolutions-dbstan)

PHPackages © 2026

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