tafhyseni/php-multi-tenancy

Handling and managing Multi Tenancy objects

1.0.1 2020-10-09 14:07 UTC

This package is auto-updated.

Last update: 2024-06-09 22:47:54 UTC


README

Latest Version on Packagist Build Status Total Downloads

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

You can install the package via composer:

composer require tafhyseni/php-multi-tenancy

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

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

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

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.

PHP Package Boilerplate

This package was generated using the PHP Package Boilerplate.