Download the PHP package jdomenechb/renew-doctrine-connection without Composer
On this page you can find all versions of the php package jdomenechb/renew-doctrine-connection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jdomenechb/renew-doctrine-connection
More information about jdomenechb/renew-doctrine-connection
Files in jdomenechb/renew-doctrine-connection
Package renew-doctrine-connection
Short Description Renews Doctrine DBAL connections that have been closed or timed out.
License MIT
Informations about the package renew-doctrine-connection
Renew Doctrine Connection
This library eases the process of renewing an existing Doctrine connection in your application that has been closed due to a timeout from the server. This might happen when the connection expires or the server has become unavailable.
When the connection is lost, the application usually throws an error like (in MySQL):
It is recommended to install this library only in daemons, consumers, PHP-only servers or very long processes, that is, any PHP project that relies solely in a lengthy PHP process to run. That does not include normal PHP applications running in web servers like Nginx or Apache, unless they have expensive algorythtms that rely on the database. Otherwise, you might be suffering some undesired overhead in your application.
Installation
Add this library to your project using Composer:
Configuration
Modify your Doctrine configuration to use the TimedRenewConnection
contained in this library as the wrapper class of Doctrine. In Symfony, for example, configuration will look like:
You can freely customize the parameter secondsToRenew
. The database connection will be renewed only after the seconds of inactivity you specify in this parameter. If it is set to 0
or not set at all, the connection will be renewed before every operation performed to the database.
For example, a good value to assign to this parameter, in MySQL, is the value of the MySQL system variable wait_timeout
.