PHPackages                             amphp/mysql - 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/mysql

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

amphp/mysql
===========

Asynchronous MySQL client for PHP based on Amp.

v3.0.1(6mo ago)3761.1M—3.9%62[5 issues](https://github.com/amphp/mysql/issues)[1 PRs](https://github.com/amphp/mysql/pulls)20MITPHPPHP &gt;=8.1CI passing

Since Nov 7Pushed 2mo ago21 watchersCompare

[ Source](https://github.com/amphp/mysql)[ Packagist](https://packagist.org/packages/amphp/mysql)[ GitHub Sponsors](https://github.com/amphp)[ RSS](/packages/amphp-mysql/feed)WikiDiscussions 3.x Synced 1mo ago

READMEChangelog (10)Dependencies (13)Versions (38)Used By (20)

amphp/mysql
===========

[](#amphpmysql)

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. `amphp/mysql` is an asynchronous MySQL client. The library implements concurrent querying by transparently distributing queries across a scalable pool of available connections. The client transparently distributes these queries across a scalable pool of available connections and does so using 100% userland PHP; there are *no external extension dependencies* (e.g. `ext/mysqli`, `ext/pdo`, etc.).

Features
--------

[](#features)

- Exposes a non-blocking API for issuing multiple MySQL queries concurrently
- Transparent connection pooling to overcome MySQL's fundamentally synchronous connection protocol
- MySQL transfer encoding support (gzip, TLS encryption)
- Support for parameterized prepared statements
- Nested transactions with commit and rollback event hooks
- Unbuffered results to reduce memory usage for large result sets
- *Full* MySQL protocol support including *all*† available commands asynchronously

† As documented in [official Mysql Internals Manual](https://dev.mysql.com/doc/internals/en/client-server-protocol.html)

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

[](#installation)

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

```
composer require amphp/mysql
```

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

[](#requirements)

- PHP 8.1+

Usage
-----

[](#usage)

More extensive code examples reside in the [`examples`](examples) directory.

```
use Amp\Mysql\MysqlConfig;
use Amp\Mysql\MysqlConnectionPool;

$config = MysqlConfig::fromString(
    "host=localhost user=username password=password db=test"
);

$pool = new MysqlConnectionPool($config);

$statement = $pool->prepare("SELECT * FROM table_name 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/mysql` 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

69

—

FairBetter than 100% of packages

Maintenance76

Regular maintenance activity

Popularity60

Solid adoption and visibility

Community43

Growing community involvement

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 50.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 ~104 days

Recently: every ~199 days

Total

37

Last Release

85d ago

Major Versions

v0.3.1 → v1.0.02018-10-14

v1.2.0 → v2.0.0-rc12019-10-30

v1.x-dev → v2.1.02020-11-10

v2.1.2 → v3.0.0-beta.12022-07-17

v2.1.3 → v3.0.0-beta.42022-12-18

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

v2.0.0-rc1PHP &gt;=7.1

v3.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 (257 commits)")[![bwoebi](https://avatars.githubusercontent.com/u/3154871?v=4)](https://github.com/bwoebi "bwoebi (170 commits)")[![prolic](https://avatars.githubusercontent.com/u/394428?v=4)](https://github.com/prolic "prolic (27 commits)")[![kelunik](https://avatars.githubusercontent.com/u/2743004?v=4)](https://github.com/kelunik "kelunik (24 commits)")[![rdlowrey](https://avatars.githubusercontent.com/u/1259291?v=4)](https://github.com/rdlowrey "rdlowrey (4 commits)")[![shtse8](https://avatars.githubusercontent.com/u/8020099?v=4)](https://github.com/shtse8 "shtse8 (4 commits)")[![marcioAlmada](https://avatars.githubusercontent.com/u/227395?v=4)](https://github.com/marcioAlmada "marcioAlmada (3 commits)")[![sagara-](https://avatars.githubusercontent.com/u/310250?v=4)](https://github.com/sagara- "sagara- (3 commits)")[![Danack](https://avatars.githubusercontent.com/u/1505719?v=4)](https://github.com/Danack "Danack (3 commits)")[![bennnjamin](https://avatars.githubusercontent.com/u/10929253?v=4)](https://github.com/bennnjamin "bennnjamin (2 commits)")[![brstgt](https://avatars.githubusercontent.com/u/331879?v=4)](https://github.com/brstgt "brstgt (2 commits)")[![dbalabka](https://avatars.githubusercontent.com/u/1269372?v=4)](https://github.com/dbalabka "dbalabka (2 commits)")[![krlv](https://avatars.githubusercontent.com/u/3404064?v=4)](https://github.com/krlv "krlv (1 commits)")[![optiman](https://avatars.githubusercontent.com/u/2707476?v=4)](https://github.com/optiman "optiman (1 commits)")[![harikt](https://avatars.githubusercontent.com/u/120454?v=4)](https://github.com/harikt "harikt (1 commits)")[![grooverdan](https://avatars.githubusercontent.com/u/462287?v=4)](https://github.com/grooverdan "grooverdan (1 commits)")[![ruifil](https://avatars.githubusercontent.com/u/1698037?v=4)](https://github.com/ruifil "ruifil (1 commits)")[![Gemorroj](https://avatars.githubusercontent.com/u/885731?v=4)](https://github.com/Gemorroj "Gemorroj (1 commits)")[![Sevavietl](https://avatars.githubusercontent.com/u/1844827?v=4)](https://github.com/Sevavietl "Sevavietl (1 commits)")[![dickson-michael](https://avatars.githubusercontent.com/u/5022251?v=4)](https://github.com/dickson-michael "dickson-michael (1 commits)")

---

Tags

amphpasyncmysqlphprevolt

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

165634.7k44](/packages/amphp-redis)[amphp/parallel

Parallel processing component for Amp.

85046.2M74](/packages/amphp-parallel)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[amphp/postgres

Asynchronous PostgreSQL client for Amp.

110509.8k27](/packages/amphp-postgres)[amphp/byte-stream

A stream abstraction to make working with non-blocking I/O simple.

393116.2M104](/packages/amphp-byte-stream)[amphp/http-server

A non-blocking HTTP application server for PHP based on Amp.

1.3k4.5M81](/packages/amphp-http-server)

PHPackages © 2026

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