PHPackages                             giant-rabbit/mysql-concentrator - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. giant-rabbit/mysql-concentrator

ActiveLibrary[HTTP &amp; Networking](/categories/http)

giant-rabbit/mysql-concentrator
===============================

A MySQL proxy server written in PHP

1.0.4(12y ago)050MITPHP

Since Nov 29Pushed 12y ago6 watchersCompare

[ Source](https://github.com/giant-rabbit/mysql-concentrator)[ Packagist](https://packagist.org/packages/giant-rabbit/mysql-concentrator)[ Docs](https://github.com/giant-rabbit/mysql-concentrator)[ RSS](/packages/giant-rabbit-mysql-concentrator/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (5)Used By (0)

MySQL Concentrator
==================

[](#mysql-concentrator)

This is a MySQL proxy server that takes several MySQL connections and "concentrates" them into a single connection to a single server. This may not seem very useful until you think about tests. One of the annoying things when doing tests on web applications is that you frequently have to do bunch of TRUNCATE or DROP TABLE statements between each test to get your database back into a known state. Doing that really slows your tests down.

Ruby on Rails gets around this to some extent by wrapping each test in a transaction (BEGIN ... ROLLBACK). It's very fast and works really well, but it only works because Rails tests all run in one process with one database connection. This technique breaks down in Rails when you introduce Cucumber tests because it launches separate web server and browser processes, so you can't wrap all the database calls in a transaction.

MySQL Concentrator helps with this problem. You can start a connection to MySQL through MySQL Concentrator in your test suite and configure your web application to also run MySQL commands through MySQL Concentrator. Then have your test suite fire a BEGIN before each test and a ROLLBACK after each test. Even if you fire off a bunch of separate processes, MySQL Concentrator will funnel all those connections into that same connection where you sent the BEGIN command and so all the database activity will happen in a transaction.

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

[](#installation)

Just grab it from the github repository. It just runs out of its directory.

Usage
-----

[](#usage)

```
php mysql-concentrator.php -h  -p

```

Configure your web application to connect to mysql on 127.0.0.1 at port 3307 instead of its normal host and port. It's normal host and port are what you should use for the command above.

Now if you are going to use it for a testing framework, just add some lines to start the transaction. Here's an example of what I did for some Behat tests in the Behat Context class:

```
/**
 * @BeforeScenario
 */
public function setupDB($event)
{
  $this->db = new PDO("mysql:host=127.0.0.1;port=3307;dbname=foo_test;", "foo", "foo");
  $this->db->exec("DROP TABLE IF EXISTS automated_testing");
  $this->db->exec("CREATE TABLE automated_testing (pristine INTEGER)");
  $this->db->exec("INSERT INTO automated_testing VALUES (1)");
  $this->db->exec("BEGIN");
  $this->db->exec("UPDATE automated_testing SET pristine = 0");
}

/**
 * @AfterScenario
 */
public function resetDB($event)
{
  $this->db->exec("ROLLBACK");
}

```

The extra stuff with "pristine" is a sort of hack so I can check and see if the web app did something to mess up the wrapping transaction. If the transaction didn't get rolled back properly "pristine" won't get set back to 1. Some statements in MySQL will cause an implicit commit. This includes pretty much all of the DDL statements like CREATE TABLE, ALTER TABLE, CREATE INDEX etc...

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

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

Total

4

Last Release

4585d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/27347?v=4)[Peter Haight](/maintainers/Dawnthorn)[@Dawnthorn](https://github.com/Dawnthorn)

---

Top Contributors

[![Dawnthorn](https://avatars.githubusercontent.com/u/27347?v=4)](https://github.com/Dawnthorn "Dawnthorn (43 commits)")

### Embed Badge

![Health badge](/badges/giant-rabbit-mysql-concentrator/health.svg)

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25025.5M80](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87930.4k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.3M84](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69122.6k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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