Skip to content

This repository provides a lightweight, raw PHP implementation for multi-tenancy support in web applications. It offers a flexible approach for managing multiple databases, allowing each tenant to have its own isolated database schema while sharing the same codebase.

License

Notifications You must be signed in to change notification settings

juborajnaofel/multidb-tenancy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multidb-tenancy

config database and domains in ./config/config.php

$dbConfig = [
	"DB_CONNECTION" => "mysql",
	"DB_HOST"=>"127.0.0.1",
	"DB_PORT"=>3306,
	"DB_DATABASE"=>"testtenancy",
	"DB_USERNAME"=>"root",
	"DB_PASSWORD"=> "",
];

$domainConfig = [
	"APP_URL" => '',
	"CENTRAL_DOMAIN" => ''
];

access current subdomain in index.php

$subdomain = $tenancy->currentSubdomain();

create a tenant in index.php

$tenancy->createTenant($dbConfig['DB_DATABASE'].'_'.$subdomain);

switch to tenant database in index.php

$db->switchTenant($dbConfig['DB_DATABASE'].'_'.$subdomain);

About

This repository provides a lightweight, raw PHP implementation for multi-tenancy support in web applications. It offers a flexible approach for managing multiple databases, allowing each tenant to have its own isolated database schema while sharing the same codebase.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages