PHPackages                             forrest79/phpgsql - 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. forrest79/phpgsql

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

forrest79/phpgsql
=================

PostgreSQL library for PHP with fluent interface for SQL query writing.

v2.0.2(3mo ago)149.0k↓12.5%5[2 issues](https://github.com/forrest79/phpgsql/issues)3BSD-3-ClausePHPPHP ^8.3CI passing

Since Oct 21Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/forrest79/phpgsql)[ Packagist](https://packagist.org/packages/forrest79/phpgsql)[ RSS](/packages/forrest79-phpgsql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (95)Used By (3)

PhPgSql
=======

[](#phpgsql)

[![Latest Stable Version](https://camo.githubusercontent.com/410a8da8204f5e0c3da2ff96b3813a7f17097f3d0a6c629266bdaa7339667805/68747470733a2f2f706f7365722e707567782e6f72672f666f727265737437392f7068706773716c2f76)](//packagist.org/packages/forrest79/phpgsql)[![Monthly Downloads](https://camo.githubusercontent.com/f86a150f7fe6d1bbf8585a5044bb48240f2700232404f23e13abd79c9de7cd9b/68747470733a2f2f706f7365722e707567782e6f72672f666f727265737437392f7068706773716c2f642f6d6f6e74686c79)](//packagist.org/packages/forrest79/phpgsql)[![License](https://camo.githubusercontent.com/1c261cf92dd35daa2ce7b306373fd5182d6a210f56f21204bbeed96cdc9e5d0f/68747470733a2f2f706f7365722e707567782e6f72672f666f727265737437392f7068706773716c2f6c6963656e7365)](//packagist.org/packages/forrest79/phpgsql)[![Build](https://github.com/forrest79/phpgsql/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/forrest79/phpgsql/actions/workflows/build.yml)[![codecov](https://camo.githubusercontent.com/011e918329661fd73066ad8ac6f57804c9ff4b1365ce8a527b610d4613474b04/68747470733a2f2f636f6465636f762e696f2f67682f666f727265737437392f7068706773716c2f67726170682f62616467652e7376673f746f6b656e3d514257414b4b55534e33)](https://codecov.io/gh/forrest79/phpgsql)

Simple and fast PHP database library for PostgreSQL with auto converting DB types to PHP and a powerful fluent interface that can be used to simply create the most of SQL queries.

- lightweight
- no magic
- no database structure reading
- automatically convert PG data types to PHP data types
- support async connect to DB and async query
- simple creating queries with parameters - char `?` for variable is automatically replaced with `$1`, `$2` and so...
    - as a variable you can pass scalar, bool, array, literal or other query

DB and fluent part can be used separately.

> Examples of how to use this library in application, how to extend it with some useful methods and a simple repository system can be found here .

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

[](#installation)

The recommended way to install PhPgSql is through Composer:

```
composer require forrest79/phpgsql
```

PhPgSql requires PHP 8.3.0 and pgsql binary extension. It doesn't work with the PDO!

If you're using [PHPStan](https://phpstan.org/) you can install [settings](https://github.com/forrest79/phpgsql-phpstan) for this great tool.

```
composer require --dev forrest79/phpgsql-phpstan
```

And if you're using [Nette framework](https://nette.org/), there is existing integration with the [Tracy](https://tracy.nette.org/) panel.

Documentation
-------------

[](#documentation)

[Complete documentation](docs/index.md) is in the `docs` directory.

> All examples are self-tested - you can be sure, it's working.

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance81

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity93

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 96.3% 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 ~28 days

Recently: every ~109 days

Total

94

Last Release

91d ago

Major Versions

v0.16.3 → v1.0.02021-07-23

v1.7.2 → v2.0.02025-10-01

PHP version history (5 changes)v0.1.0PHP &gt;=7.1

v0.16.0PHP ^7.1 | ^8.0

v1.1.0PHP ^7.2 | ^8.0

v1.5.0PHP ^8.1

v2.0.0PHP ^8.3

### Community

Maintainers

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

---

Top Contributors

[![forrest79](https://avatars.githubusercontent.com/u/160766?v=4)](https://github.com/forrest79 "forrest79 (315 commits)")[![klapuch](https://avatars.githubusercontent.com/u/17772194?v=4)](https://github.com/klapuch "klapuch (8 commits)")[![vrana](https://avatars.githubusercontent.com/u/117453?v=4)](https://github.com/vrana "vrana (3 commits)")[![SebLours](https://avatars.githubusercontent.com/u/5138394?v=4)](https://github.com/SebLours "SebLours (1 commits)")

---

Tags

phpdatabasepostgresqlfluent

### Embed Badge

![Health badge](/badges/forrest79-phpgsql/health.svg)

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

###  Alternatives

[mevdschee/php-crud-api

Single file PHP script that adds a REST API to a SQL database.

3.7k63.8k9](/packages/mevdschee-php-crud-api)[vcian/laravel-db-auditor

Database DB Auditor provide leverage to audit your MySql,sqlite, PostgreSQL database standards and also provide options to add constraints in table.

28535.1k1](/packages/vcian-laravel-db-auditor)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)

PHPackages © 2026

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