Download the PHP package connehito/cakephp-master-replica without Composer
On this page you can find all versions of the php package connehito/cakephp-master-replica. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download connehito/cakephp-master-replica
More information about connehito/cakephp-master-replica
Files in connehito/cakephp-master-replica
Package cakephp-master-replica
Short Description Provides the features for multiple database connections as master/replica and switching.
License MIT
Informations about the package cakephp-master-replica
[Archived] CakePHP Master Replica Plugin
Use CakePHP native features introduced from 4.5 if you want to switch Database roles.
This project has been archived and is no longer actively maintained because several years have passed without active maintenance.
We appreciate the support and contributions from the community over the years. While this repository will remain available in read-only mode, there will be no further updates or maintenance. Thank you for your understanding and support.
The datasource for CakePHP.This plugin enables one-connection to act as two(or more) roles, like master(read-write) and replica(read-only).
Supports
- PHP 7.2+
- CakePHP 4.0+
:bulb: For CakePHP3.x, use 1.x
branch.
Usage
- Install plugin
composer require connehito/cakephp-master-replica
- Set your connections(e.g. in
config/app.php
datasource. It requiresroles
property.
Example
Set up your database configuration.
- Databse-A(for master): mysql;host=db-host,databasename=app_db,login=root,pass=password
- Databse-B(for replica): mysql;host=db-host,databasename=app_db,login=read-only-user,pass=another-password
- Databse-C(for replica): mysql;host=replica-host,databasename=app_db,login=read-only-user,pass=another-password
In each roles, you can set specific values and override them.
In app, now you can connect to database master or replica db as you like :tada:
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Connehito/cakephp-master-replica
- Please fix all problems with PHPUnit, PHPStan, PHP_CodeSniffer before send pull request :smile:
- You can build development env in local with
tests/test_app/docker-compose.yml
:horse_racing:
License
The plugin is available as open source under the terms of the MIT License.