Skip to content

This project is a multi-tenant implementation using the Phinx library for database migrations.

License

Notifications You must be signed in to change notification settings

kalider/phinx-tenant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kalaider Phinx Multi-Tenant

This project is a multi-tenant implementation using the Phinx library for database migrations.

Installation

To install the library, use Composer:

composer require kalider/phinx-tenant

Usage

Configuration

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',
        ],
    ]
];

Running Migrations

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

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes.

Contact

For any questions or inquiries, please contact [email protected].

About

This project is a multi-tenant implementation using the Phinx library for database migrations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages