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 :)
You can install the package via composer:
composer require tafhyseni/php-multi-tenancy
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' => ''
)
);
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);
composer require --dev phpunit/phpunit
./vendor/bin/phpunit tests/TenancyTest
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email tafhyseni@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the PHP Package Boilerplate.