Download the PHP package motomedialab/maxscale-connector without Composer
On this page you can find all versions of the php package motomedialab/maxscale-connector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download motomedialab/maxscale-connector
More information about motomedialab/maxscale-connector
Files in motomedialab/maxscale-connector
Package maxscale-connector
Short Description Fixes database connection errors when routing Laravel database connections via MariaDB MaxScale
License MIT
Informations about the package maxscale-connector
Laravel MariaDB MaxScale Connector
A simple package designed to provide a fix for the existing Illuminate\Database\Connectors\MySQLConnector
class.
When connecting to MaxScale using Laravel, the $connection->exec("use {$config['database']};");
command is run,
not only creating a surplus query but also triggering a database connection error when using MariaDB MaxScale.
Within MaxScale logs, you'll see an error similar to:
The reason for this, is that Laravel is trying to establish a connection with '`database_name`' (backticks) when it should simply be connecting to 'database_name' (no backticks).
As the database name has already been declared within the PDO DSN (see PR #34389), the offending line of code is effectively surplus to requirements already. All this package does is remove the surplus database selection by overriding the existing MySQL connector to remove the offending lines of code.
Installation
Install via composer composer require motomedialab/maxscale-connector
Within your config/database.php
you have two options:
-
Update your
database.connections.mysql.driver
config flag tomaxscale
- Create a new configuration for MaxScale
- Copy the entire
database.connections.mysql
config array - Rename the key to
maxscale
- Change the driver flag
database.connections.maxscale.driver
tomaxscale
- Update your
.env
file to reflect this change, e.g.DB_CONNECTION=maxscale
- Copy the entire
Once one of the above options have been completed, you should be able to connect to your MaxScale instance via Laravel no problem.
Notes
- While this package was built to resolve Laravel MaxScale issues, the package will still work with MySQL and remove the surplus query being performed on each load
All versions of maxscale-connector with dependencies
illuminate/support Version ^7.0|^8.0
illuminate/database Version ^7.0|^8.0