PHPackages                             plasma/driver-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. plasma/driver-mysql

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

plasma/driver-mysql
===================

The MySQL/MariaDB driver for Plasma.

v0.4.0(5y ago)13141[7 issues](https://github.com/PlasmaPHP/driver-mysql/issues)Apache-2.0PHPPHP &gt;=7.1

Since Dec 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/PlasmaPHP/driver-mysql)[ Packagist](https://packagist.org/packages/plasma/driver-mysql)[ RSS](/packages/plasma-driver-mysql/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (12)Versions (8)Used By (0)

Plasma Driver MySQL/MariaDB [![Build Status](https://camo.githubusercontent.com/24e4a8ff30f178d25894b1b8ac0b8c51ac53e09d03c1a55abaa0573f5bcceda9/68747470733a2f2f7472617669732d63692e6f72672f506c61736d615048502f6472697665722d6d7973716c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/PlasmaPHP/driver-mysql) [![Build Status](https://camo.githubusercontent.com/1a01fa528ea33c80b863d51c111a5d4986f6a4e4699dde0a5179e43ff8a7f982/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f506c61736d615048502f6472697665722d6d7973716c2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/PlasmaPHP/driver-mysql/build-status/master) [![Code Coverage](https://camo.githubusercontent.com/64641ff0339b4fb90957e6d23c2f63871005c299d52adef8dc1a5a3aaa6f76d3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f506c61736d615048502f6472697665722d6d7973716c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/PlasmaPHP/driver-mysql/?branch=master)
=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#plasma-driver-mysqlmariadb---)

Plasma provides an asynchronous, non-blocking (data access) Database Abstraction Layer. This is the MySQL/MariaDB driver for Plasma.

The driver uses ReactPHP to asychronously interface with the database server.

The driver supports setting a connection charset through the driver options, it should be noted that the default is `utf8mb4` (UTF-8), which is a character set you should use all the way through.

It should also be noted, that MySQL versions, which support the `FOUND_ROWS` flag, can return a non-zero value when using `StreamQueryResultInterface::getAffectedRows()` for `SELECT` queries.

Getting Started
===============

[](#getting-started)

You can install this component by using `composer`. The command is

```
composer require plasma/driver-mysql

```

After you've used composer to install the components and the dependencies, you get started by creating an instance of the factory.

The factory takes a loop instance and an array of options (see the factory class documentation for the available options).

The factory also gives you the ability to asychronously interface with the filesystem using `react/filesystem`, if a `LOCAL INFILE` request ever occurres.

Additionally you can create your own auth plugins, if your database server uses an authentication plugin this driver doesn't support (yet).

```
use Plasma\Client;
use Plasma\Drivers\MySQL\DriverFactory;
use React\EventLoop\Factory;

$loop = Factory::create();

$factory = new DriverFactory($loop, array());
$client = Client::create($factory, 'user:password@localhost:3306/database', array());

// Code which uses the client to run queries against the database

$loop->run();
```

Unix socket connections are supported using the `unix://` scheme, so the example connect uri would look like this.

```
unix://user:password@localhost/database

```

When using unix socket connections without a database, a trailing slash is required. When using `localhost` as unix socket path, the default mysql path will be used.

Cursors
=======

[](#cursors)

MySQL supports cursors since 5.7 (MariaDB 10.3). As such the driver will reject MySQL versions below 5.7, respectively MariaDB 10.3, as they do not support cursors (even though the capabilities may say otherwise).

If known at driver method call time, the driver will throw a `LogicException`, or postpone it and reject the promise with a `LogicException`.

Compression
===========

[](#compression)

By default packet compression is enabled and all packets equal to or larger than 50 bytes are automatically compressed (as long as zlib is available). This can be disabled using the `compression.enable` flag.

Server OK Response Messages
===========================

[](#server-ok-response-messages)

The driver exposes every OK response message packet of the server through a Plasma Client event called `serverOkMessage`. The argument is an instance of `Messages\OkResponseMessage`.

As such advanced users can check the status of the server and perform certain actions, or just log it for pure statistics purposes.

Type Extensions
===============

[](#type-extensions)

This driver uses a type extensions manager registered under the name `driver-mysql`. When decoding rows received from the database, the type extensions can get two different type of values to decode, depending on the used protocol.

When using the text protocol (regular queries), then the type extensions get the raw value as string.

However when using the binary protocol (prepared statements), then the type extensions get the used `\Plasma\BinaryBuffer` instance. It must be used with care. Reading too much from it can lead into dropped row, because the remaining fields can not be properly decoded.

Documentation
=============

[](#documentation)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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 ~200 days

Total

5

Last Release

1901d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/85dbed21ee3f899a9fac2a46423ba9b5fc227ab189da1a54787e82e1222aa472?d=identicon)[gitneko](/maintainers/gitneko)

---

Top Contributors

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

---

Tags

abstractionabstraction-layerasyncasynchronousdatabasemariadbmysqlphpphp-libraryphp7plasmaplasmaphpreactphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[clue/redis-react

Async Redis client implementation, built on top of ReactPHP.

28210.5M45](/packages/clue-redis-react)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

134391.5k12](/packages/rector-rector-src)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)[react/mysql

Async MySQL database client for ReactPHP.

340421.0k29](/packages/react-mysql)[clue/docker-react

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.

113154.9k1](/packages/clue-docker-react)[voryx/pgasync

Async Reactive Postgres Driver for PHP (Non-blocking)

11294.0k4](/packages/voryx-pgasync)

PHPackages © 2026

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