PHPackages                             connehito/cakephp2-master-replica - 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. [Database &amp; ORM](/categories/database)
4. /
5. connehito/cakephp2-master-replica

AbandonedArchivedCakephp-plugin[Database &amp; ORM](/categories/database)

connehito/cakephp2-master-replica
=================================

Provides the features for multiple database connections as master/replica and switching in Datasource.

1.0.0(6y ago)74.1k↓80%MITPHP

Since Jun 19Pushed 1y agoCompare

[ Source](https://github.com/Connehito/cakephp2-master-replica)[ Packagist](https://packagist.org/packages/connehito/cakephp2-master-replica)[ RSS](/packages/connehito-cakephp2-master-replica/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)DependenciesVersions (4)Used By (0)

\[Archived\] CakePHP Master Replica Plugin
==========================================

[](#archived-cakephp-master-replica-plugin)

This project has been archived and is no longer actively maintained. The project has been archived due to that official support for CakePHP2 has ended several years ago. 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(2.x).This plugin enables one-connection to act as two(or more) roles, like master(read-write) and replica(read-only).

[![Build Status](https://camo.githubusercontent.com/e1bf110fb35f2577c91af27bf8fb3fd871f3318dab4a0e06f517c5d31545e78f/68747470733a2f2f7472617669732d63692e6f72672f436f6e6e656869746f2f63616b65706870322d6d61737465722d7265706c6963612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Connehito/cakephp2-master-replica)[![codecov](https://camo.githubusercontent.com/d214558306a860b10c3d261b4202b1b30a43d92d2a5e3034edf8e556b92b1cd4/68747470733a2f2f636f6465636f762e696f2f67682f436f6e6e656869746f2f63616b65706870322d6d61737465722d7265706c6963612f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Connehito/cakephp2-master-replica)[![Latest Stable Version](https://camo.githubusercontent.com/d187a61689b44aa59bfbf52e063768f01383f9c0f112d96fff5a380992e03831/68747470733a2f2f706f7365722e707567782e6f72672f636f6e6e656869746f2f63616b65706870322d6d61737465722d7265706c6963612f762f737461626c65)](https://packagist.org/packages/Connehito/cakephp2-master-replica)[![Total Downloads](https://camo.githubusercontent.com/bb285a11bcec67cfde5bb125c4de9516a1febd3ce533c7a6fe844f1ae1712323/68747470733a2f2f706f7365722e707567782e6f72672f636f6e6e656869746f2f63616b65706870322d6d61737465722d7265706c6963612f646f776e6c6f616473)](https://packagist.org/packages/Connehito/cakephp2-master-replica)[![License](https://camo.githubusercontent.com/86f0d736cae91bfc19087a537212bf436e4ca74e2969017e01931dd70e79d598/68747470733a2f2f706f7365722e707567782e6f72672f636f6e6e656869746f2f63616b65706870322d6d61737465722d7265706c6963612f6c6963656e7365)](https://packagist.org/packages/Connehito/cakephp2-master-replica)

Supports
--------

[](#supports)

- PHP 5.6+ / 7.0+
- CakePHP 2.7+
- MySQL

Usage
-----

[](#usage)

1. Download the repository to set `app/Plugin/MasterReplica`
2. Load plugin in `app/Config/bootstrap.php` like `CakePlugin::load('MasterReplica');` or `CakePlugin::loadAll();`
3. Set your `database.php` with `MasterReplica.Database/MasterReplicaMysql` datasource. It requires `connections` property.

### Example

[](#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=replica-host,databasename=app\_db,login=read-only-user,pass=another-password

```
// database.php
