PHPackages                             tafhyseni/php-multi-tenancy - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tafhyseni/php-multi-tenancy

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tafhyseni/php-multi-tenancy
===========================

Handling and managing Multi Tenancy objects

1.0.1(5y ago)9721MITPHP

Since Jan 9Pushed 5y ago1 watchersCompare

[ Source](https://github.com/tafhyseni/php-multi-tenancy)[ Packagist](https://packagist.org/packages/tafhyseni/php-multi-tenancy)[ RSS](/packages/tafhyseni-php-multi-tenancy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Fast and simple dealing with Php Multi Tenancy
==============================================

[](#fast-and-simple-dealing-with-php-multi-tenancy)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d28a99af3543a8e5ee186b5f29883fa3a9c10d42c493c089b343fd5c082029b7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746166687973656e692f7068702d6d756c74692d74656e616e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tafhyseni/php-multi-tenancy)[![Build Status](https://camo.githubusercontent.com/95ac10f93d5439916e1b751622866dd2c783c3558ad62e35b68d1d68d18efdba/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746166687973656e692f7068702d6d756c74692d74656e616e63792f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/tafhyseni/php-multi-tenancy)[![Total Downloads](https://camo.githubusercontent.com/e633271a3072b0ccf604ba03704735409f84b47e5081124666652a5fa04fe813/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746166687973656e692f7068702d6d756c74692d74656e616e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tafhyseni/php-multi-tenancy)

Simple PHP package to help you control, create and manage Tenancy architectural databases.

Currently this works only on MySQL, but other databases will be added shortly! Also, this does work only on same hostname databases, it will also soon extended to support different hostnames..

Want to contribute.. you're welcome :)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require tafhyseni/php-multi-tenancy
```

Initialization
--------------

[](#initialization)

Initialization is simple as long as you do not forget to pass configuration properly

```
use Tafhyseni\PhpMultiTenancy\Tenancy;
$tenancy = new Tenancy(
    array(
        'hostname' => '127.0.0.1',
        'username' => 'root',
        'password' => '',
        'database' => 'test',
        'tenancy_hostname' => '127.0.0.1',
        'tenancy_username' => 'root',
        'tenancy_password' => ''
    )
);
```

Usage
-----

[](#usage)

Generating an entire tenancy schema with all tables and data

```
$name = $tenancy->generate(NULL, array(), true);
```

Generating an entire tenancy schema with only some tables and data

```
$name = $tenancy->generate(NULL, array('table_to_clone_1', 'table_to_clone_2'), true);
```

Generating an entire tenancy schema with only some tables, no data and specified tenancy name

```
$name = $tenancy->generate('my_tenancy_db', array('table_to_clone_1'), data);
```

### Testing

[](#testing)

```
composer require --dev phpunit/phpunit
./vendor/bin/phpunit tests/TenancyTest
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Mustafe Hyseni](https://github.com/tafhyseni)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

PHP Package Boilerplate
-----------------------

[](#php-package-boilerplate)

This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Every ~274 days

Total

2

Last Release

2048d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a3563c0eeabaace1af7b757a44f78451adf5cbf3cdde2b68940cbc4ed8414334?d=identicon)[tafhyseni](/maintainers/tafhyseni)

---

Top Contributors

[![tafhyseni](https://avatars.githubusercontent.com/u/20110604?v=4)](https://github.com/tafhyseni "tafhyseni (22 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tafhyseni-php-multi-tenancy/health.svg)

```
[![Health](https://phpackages.com/badges/tafhyseni-php-multi-tenancy/health.svg)](https://phpackages.com/packages/tafhyseni-php-multi-tenancy)
```

###  Alternatives

[hi-folks/statistics

PHP package that provides functions for calculating mathematical statistics of numeric data.

398103.5k](/packages/hi-folks-statistics)[humanmade/coding-standards

Human Made Coding Standards

161424.0k49](/packages/humanmade-coding-standards)[social-links/social-links

PHP library to generate share buttons

112338.6k2](/packages/social-links-social-links)[malukenho/docheader

A small library to check header docs

68380.8k136](/packages/malukenho-docheader)[mdurrant/php-binary-reader

Lightweight binary reader for PHP

62100.3k7](/packages/mdurrant-php-binary-reader)[gkralik/php-uglifyjs

PHP Javascript packer

35292.3k7](/packages/gkralik-php-uglifyjs)

PHPackages © 2026

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