This project is a multi-tenant implementation using the Phinx library for database migrations.
To install the library, use Composer:
composer require kalider/phinx-tenant
Create a phinx-tenant.php
configuration file in the root of your project:
return [
'type' => 'database', // database, array
// if database type
'database' => [
'connection' => [
'adapter' => 'mysql',
'host' => 'localhost',
'name' => 'multi_tenant_db',
'user' => 'root',
'pass' => 'kudabelang',
],
'table' => 'tenants',
'fields' => [
'host' => 'host',
'name' => 'name',
'user' => 'user',
'pass' => 'pass',
],
// if wheres condition
'conditions' => [
'status' => 1
]
],
// if array type
'tenants' => [
[
'host' => 'localhost',
'name' => 'tenant1',
'user' => 'root',
'pass' => 'root',
],
]
];
To run migrations for a specific tenant, use the following command:
php vendor/bin/phinx-tenant migrate
# different phinx config
php vendor/bin/phinx-tenant migrate -c phinx-master.php
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any changes.
For any questions or inquiries, please contact [email protected].