PHPackages                             amphp/postgres - 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. amphp/postgres

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

amphp/postgres
==============

Asynchronous PostgreSQL client for Amp.

v2.2.1(4mo ago)109584.1k↓17.4%20[5 issues](https://github.com/amphp/postgres/issues)20MITPHPPHP &gt;=8.1CI failing

Since Jun 21Pushed 4mo ago10 watchersCompare

[ Source](https://github.com/amphp/postgres)[ Packagist](https://packagist.org/packages/amphp/postgres)[ Docs](https://amphp.org)[ GitHub Sponsors](https://github.com/amphp)[ RSS](/packages/amphp-postgres/feed)WikiDiscussions 2.x Synced yesterday

READMEChangelog (10)Dependencies (8)Versions (37)Used By (20)

amphp/postgres
==============

[](#amphppostgres)

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. `amphp/postgres` is an asynchronous Postgres client. The library implements concurrent querying by transparently distributing queries across a scalable pool of available connections. Either [ext-pgsql](https://secure.php.net/pgsql) (bundled with PHP) or [pecl-pq](https://pecl.php.net/package/pq) are required.

Features
--------

[](#features)

- Exposes a non-blocking API for issuing multiple Postgres queries concurrently
- Transparent connection pooling to overcome Postgres' fundamentally synchronous connection protocol
- Support for parameterized prepared statements
- Nested transactions with commit and rollback event hooks
- Unbuffered results to reduce memory usage for large result sets
- Support for sending and receiving notifications

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

[](#installation)

This package can be installed as a [Composer](https://getcomposer.org/) dependency.

```
composer require amphp/postgres
```

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

[](#requirements)

- PHP 8.1+
- [ext-pgsql](https://secure.php.net/pgsql) or [pecl-pq](https://pecl.php.net/package/pq)

Note: [pecl-ev](https://pecl.php.net/package/ev) is not compatible with ext-pgsql. If you wish to use pecl-ev for the event loop backend, you must use pecl-pq.

Documentation &amp; Examples
----------------------------

[](#documentation--examples)

Prepared statements and parameterized queries support named placeholders, as well as `?` and standard numeric (i.e. `$1`) placeholders.

Row values are cast to their corresponding PHP types. For example, integer columns will be an `int` in the result row array.

More examples can be found in the [`examples`](examples) directory.

```
use Amp\Postgres\PostgresConfig;
use Amp\Postgres\PostgresConnectionPool;

$config = PostgresConfig::fromString("host=localhost user=postgres db=test");

$pool = new PostgresConnectionPool($config);

$statement = $pool->prepare("SELECT * FROM test WHERE id = :id");

$result = $statement->execute(['id' => 1337]);
foreach ($result as $row) {
    // $row is an associative-array of column values, e.g.: $row['column_name']
}
```

Versioning
----------

[](#versioning)

`amphp/postgres` follows the [semver](http://semver.org/) semantic versioning specification like all other `amphp` packages.

Security
--------

[](#security)

If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.

License
-------

[](#license)

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

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance76

Regular maintenance activity

Popularity54

Moderate usage in the ecosystem

Community38

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 95.7% 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 ~88 days

Recently: every ~125 days

Total

37

Last Release

128d ago

Major Versions

v0.2.1 → v1.0.02018-10-14

v1.4.3 → v2.0.0-beta.12022-07-17

v1.4.5 → v2.0.0-beta.32023-05-01

PHP version history (4 changes)v1.0.0PHP ^7.0

v1.2.0PHP ^7.1

v1.3.2PHP &gt;=7.1

v2.0.0-beta.1PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1628287?v=4)[Aaron Piotrowski](/maintainers/Trowski)[@trowski](https://github.com/trowski)

![](https://www.gravatar.com/avatar/12852217f3369e8144bc9ce6ac2a2341c28c5512c5b3df5749bfbbd45b6877ff?d=identicon)[kelunik](/maintainers/kelunik)

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

---

Top Contributors

[![trowski](https://avatars.githubusercontent.com/u/1628287?v=4)](https://github.com/trowski "trowski (352 commits)")[![prolic](https://avatars.githubusercontent.com/u/394428?v=4)](https://github.com/prolic "prolic (5 commits)")[![PeeHaa](https://avatars.githubusercontent.com/u/1330296?v=4)](https://github.com/PeeHaa "PeeHaa (2 commits)")[![enumag](https://avatars.githubusercontent.com/u/539462?v=4)](https://github.com/enumag "enumag (2 commits)")[![kelunik](https://avatars.githubusercontent.com/u/2743004?v=4)](https://github.com/kelunik "kelunik (2 commits)")[![uasan](https://avatars.githubusercontent.com/u/27836154?v=4)](https://github.com/uasan "uasan (1 commits)")[![bwoebi](https://avatars.githubusercontent.com/u/3154871?v=4)](https://github.com/bwoebi "bwoebi (1 commits)")[![DaveRandom](https://avatars.githubusercontent.com/u/2396425?v=4)](https://github.com/DaveRandom "DaveRandom (1 commits)")[![PNixx](https://avatars.githubusercontent.com/u/1117351?v=4)](https://github.com/PNixx "PNixx (1 commits)")[![Bilge](https://avatars.githubusercontent.com/u/470626?v=4)](https://github.com/Bilge "Bilge (1 commits)")

---

Tags

amphpasyncphppostgrespostgresqlasyncasynchronousdatabasepostgresqlpgsqldbpostgre

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/amphp-postgres/health.svg)

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

###  Alternatives

[doctrine/dbal

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

9.7k605.0M6.8k](/packages/doctrine-dbal)[aura/sqlquery

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

4883.1M38](/packages/aura-sqlquery)[amphp/mysql

Asynchronous MySQL client for PHP based on Amp.

3771.1M36](/packages/amphp-mysql)[amphp/sql-common

Common classes for non-blocking SQL implementations.

131.3M7](/packages/amphp-sql-common)[amphp/sql

Asynchronous SQL client for Amp.

201.3M14](/packages/amphp-sql)[aura/sqlschema

Provides facilities to read table names and table columns from a database using PDO.

44243.2k4](/packages/aura-sqlschema)

PHPackages © 2026

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