PHPackages                             silverstripe-australia/silverstripe-splitdb - 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. silverstripe-australia/silverstripe-splitdb

ActiveSilverstripe-module[Database &amp; ORM](/categories/database)

silverstripe-australia/silverstripe-splitdb
===========================================

Provides functionality to configure separate read/write database connections

1.0.0(10y ago)4591[1 issues](https://github.com/nyeholt/silverstripe-splitdb/issues)[2 PRs](https://github.com/nyeholt/silverstripe-splitdb/pulls)BSD-3-ClausePHP

Since Sep 29Pushed 10y ago2 watchersCompare

[ Source](https://github.com/nyeholt/silverstripe-splitdb)[ Packagist](https://packagist.org/packages/silverstripe-australia/silverstripe-splitdb)[ RSS](/packages/silverstripe-australia-silverstripe-splitdb/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

SilverStripe Split Database module
==================================

[](#silverstripe-split-database-module)

This module contains an implementation of Read/Write splitting for database queries to allow for master/slave database implementations

Basic Usage
-----------

[](#basic-usage)

For using aspects, which is effectively database agnostic, read the 'ReadWriteSplitterAspect' section. For using a custom database class against MySQL, read the 'ReadWriteMySQLDatabase' section.

### ReadWriteSplitterAspect

[](#readwritesplitteraspect)

Use this aspect to direct READ queries to a particular database, and WRITE queries (ie queries that modify) to a specific master server (that is replicating to those slaves). It is assumed replication is managed externally to SilverStripe.

Add configuration in your project along the lines of

```

Injector:
  WriteMySQLDatabase:
    class: MySQLDatabase
    constructor:
      - type: MySQLDatabase
        server: write.master.database.hostname
        username: user
        password: pass
        database: project_database
  ProxiedMySQLDatabase:
    class: MySQLDatabase
    constructor:
      - type: MySQLDatabase
        server: readonly.slavecluster.hostname
        username: user
        password: pass
        database: project_database
  MySQLWriteDbQueryAspect:
    class: \SilverStripe\Aspects\Database\ReadWriteSplitterAspect
    properties:
      writeDb: %$WriteMySQLDatabase
  MySQLDatabase:
    class: AopProxyService
    properties:
      proxied: %$ProxiedMySQLDatabase
      beforeCall:
        query:
          - %$MySQLWriteDbQueryAspect
        manipulate:
          - %$MySQLWriteDbQueryAspect
        getGeneratedID:
          - %$MySQLWriteDbQueryAspect
        affectedRows:
          - %$MySQLWriteDbQueryAspect

```

### ReadWriteMySQLDatabase

[](#readwritemysqldatabase)

Similar to the previous ReadWrite aspect, the ReadWriteMySQLDatabase relies on setting up a separate write database connection for directing queries to. So the initial database configuration is the same as usual, however instead of using *MySQLDatabase*, use *ReadWriteMySQLDatabase*(or *ReadWriteSQLiteDatabase*). This configuration must point to the *readonly*database.

Then, via YAML config, create configuration for the *write* specific database (note that the configured Injector object MUST be called *SplitterWriteDatabase*)

```

Injector:
  SplitterWriteDatabase:
    class: MySQLDatabase
    constructor:
      - type: MySQLDatabase
        server: write.master.database.hostname
        username: user
        password: pass
        database: project_database

```

Maintainer Contacts
-------------------

[](#maintainer-contacts)

- Marcus Nyeholt

Requirements
------------

[](#requirements)

- SilverStripe 3.1.?

License
-------

[](#license)

This module is licensed under the BSD license at

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3932d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/25cb1c56a7ab949d1e6b28a2a04862ce1cffe1799a291e1797f8dfd33cd83716?d=identicon)[nyeholt](/maintainers/nyeholt)

---

Top Contributors

[![nyeholt](https://avatars.githubusercontent.com/u/161730?v=4)](https://github.com/nyeholt "nyeholt (3 commits)")

---

Tags

databasesilverstripe

### Embed Badge

![Health badge](/badges/silverstripe-australia-silverstripe-splitdb/health.svg)

```
[![Health](https://phpackages.com/badges/silverstripe-australia-silverstripe-splitdb/health.svg)](https://phpackages.com/packages/silverstripe-australia-silverstripe-splitdb)
```

###  Alternatives

[silverstripe/postgresql

SilverStripe now has tentative support for PostgreSQL ('Postgres')

16258.7k2](/packages/silverstripe-postgresql)[silverstripe/mssql

Adds MSSQL support to SilverStripe

157.8k1](/packages/silverstripe-mssql)[brettt89/silverstripe-garbage-collector

SilverStripe Garbage Collector module

1010.7k](/packages/brettt89-silverstripe-garbage-collector)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
