2017 © Pedro Peláez
 

library doctrine-reconnect

Zend Framework 2 module which attempts to reconnect when the database has 'gone away'

image

bushbaby/doctrine-reconnect

Zend Framework 2 module which attempts to reconnect when the database has 'gone away'

  • Thursday, June 30, 2016
  • by bushbaby
  • Repository
  • 3 Watchers
  • 5 Stars
  • 3,998 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

BsbDoctrineReconnect

Small Zend Framework 2 module which attempts to reconnect when the database has 'gone away'., (*1)

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Build Status Code Coverage Scrutinizer Code Quality Dependency Status, (*3)

In order to do this it overrides Doctrine DBAL Driver provided by the DoctrineORMModule., (*4)

I did not invent this method. I just liked it and thought it deserved a zf2 module so it can be reused easily. Credits ought to go to circlical., (*5)

Installation

php composer.phar require bushbaby/doctrine-reconnect

Then add BsbDoctrineReconnect to your config/application.config.php., (*6)

Adjust your Doctrine DB Config

Copy the config/bsb-doctrine-reconnect.local.php.dist to your config/autoload/config/bsb-doctrine-reconnect.local.php directory and override the specified driverClass for each connection you have have defined., (*7)

<?php
return array(
    'doctrine' => array(
        'connection' => array(
            'orm_default' => array(
                'driverClass' => 'BsbDoctrineReconnect\DBAL\Driver\PDOMySql\Driver',
                'wrapperClass' => 'BsbDoctrineReconnect\DBAL\Connection',

                'params' => array(
                    'driverOptions' => array(
                        'x_reconnect_attempts' => 10,
                    ),
                )
            )
        )
    ),
);

Test

You can manually test this actually works by connecting to mysql from the cli and killing the appropriate connection;, (*8)

mysql> SHOW PROCESSLIST;
+----+------+-----------+----------+---------+------+-------+------------------+
| Id | User | Host      | db       | Command | Time | State | Info             |
+----+------+-----------+----------+---------+------+-------+------------------+
|  1 | root | localhost | database | Sleep   |    1 |       | NULL             |
|  4 | root | localhost | NULL     | Query   |    0 | NULL  | SHOW PROCESSLIST |
+----+------+-----------+----------+---------+------+-------+------------------+
4 rows in set (0.00 sec)

mysql> KILL 1;
Query OK, 0 rows affected (0.00 sec)

Known limitations

This method only works for non transactional statements., (*9)

The Versions

09/01 2015

0.1.1

0.1.1.0 https://github.com/bushbaby/BsbDoctrineReconnect

Zend Framework 2 module which attempts to reconnect when the database has 'gone away'

  Sources   Download

MIT

The Requires

 

The Development Requires

zf2 doctrine

04/01 2015

0.1.0

0.1.0.0 https://github.com/bushbaby/BsbDoctrineReconnect

Zend Framework 2 module which attempts to reconnect when the database has 'gone away'

  Sources   Download

MIT

The Requires

 

The Development Requires

zf2 doctrine

21/01 2014

0.0.1-beta1

0.0.1.0-beta1 https://github.com/bushbaby/BsbDoctrineReconnect

Zend Framework 2 module which attempts to reconnect when the database has 'gone away'

  Sources   Download

MIT

The Requires

 

zf2 doctrine