hakam / multi-tenancy-bundle
Symfony bundle to extend doctrine to support db switcher and multi tenants
Installs: 22 371
Dependents: 0
Suggesters: 0
Security: 0
Stars: 95
Watchers: 7
Forks: 31
Open Issues: 5
Type:symfony-bundle
Requires
- php: ^8.1|^8.2|^8.3
- doctrine/annotations: ^2.0
- doctrine/doctrine-bundle: ^2.7
- doctrine/doctrine-migrations-bundle: ^3.0
- symfony/config: ^5.4.1 | ^v6.4.0|^7.0
- symfony/dependency-injection: ^5.4.1| ^v6.4.0|^7.0
- symfony/filesystem: ^6.4|^7.0
- symfony/http-kernel: ^5.4.1| ^v6.4.0|^7.0
- symfony/orm-pack: ^2.0
Requires (Dev)
- doctrine/doctrine-fixtures-bundle: ^3.6
- phpunit/phpunit: ^9.5
- symfony/phpunit-bridge: ^5.4 | ^v6.4.0|^7.0
Suggests
- doctrine/doctrine-fixtures-bundle: Required to load fixtures for tenants and main database
- dev-master
- v2.8.3
- v2.8.2
- v2.8.1
- v2.8.0
- 2.7.1
- 2.7.0
- v2.6.0
- v2.5.4
- v2.5.3
- v2.5.2.x-dev
- v2.5.2
- v2.5.1.x-dev
- v2.5.1
- v2.5.0
- v2.0.1
- v2.0.0
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.2
- dev-Supprot-Pluggable-TenantDbConfigurationInterface
- dev-Install-only-dist
- dev-create-db-async
- dev-dev
- dev-add-symfony-flex-contrib-recipes
- dev-Add-Tenant-Fixture-commands
- dev-Implement-Bulk-create-and-migrate-commands
- dev-fix-wrong-dir-check
- dev-40-question-multi-tenancy-with-multi-database
- dev-35-doctrine-dbal-4-multiple-changes-and-deprecations
- dev-25-deprecated-the-url-connection-parameter-dbal-36
- dev-Remove-php-deprecated-versions-
- dev-28-unable-to-use-dql-string_functions
- dev-Create-database-from-command
- dev-create-db-command
- dev-Add-github-actions
- dev-issues/13-Diff-command-Check-the-Main-db-if-the-Tenant-DbId-is-NULL
- dev-Non-existent-service
This package is auto-updated.
Last update: 2025-07-11 20:23:22 UTC
README
๐ Full Documentation: https://ramyhakam.github.io/multi_tenancy_bundle/
๐งฉ Overview
The Symfony Multi-Tenancy Bundle enables scalable, production-ready multi-tenancy for Symfony applications.
Ideal for SaaS platforms, region-based services, and multi-vendor e-commerce systems, this bundle is built around a database-per-tenant architecture, giving each tenant:
- A fully isolated database
- Independent schema and migrations
- Configurable connection parameters (host, driver, credentials)
It integrates seamlessly with Doctrine and Symfonyโs service container, offering:
- Automatic tenant database switching at runtime via
SwitchDbEvent
- Separate migration and fixture paths for main vs. tenant databases
- Dedicated
TenantEntityManager
service for runtime isolation
For full usage examples and advanced configuration, see the documentation.
๐ Quick Installation
1. Via Symfony Flex (Recommended)
composer require hakam/multi-tenancy-bundle
Symfony Flex will automatically scaffold config, register the bundle, and create:
src/Entity/Main/
src/Entity/Tenant/
migrations/Main/
migrations/Tenant/
2. Manual Installation
composer require hakam/multi-tenancy-bundle
Then register in config/bundles.php
, copy the example hakam_multi_tenancy.yaml
from docs, and create the required directories.
๐ Useful Links
- Full Documentation: [https://ramyhakam.github.io/multi_tenancy_bundle/]
- GitHub: https://github.com/RamyHakam/multi_tenancy_bundle
- Packagist: https://packagist.org/packages/hakam/multi-tenancy-bundle
- Example Project: https://github.com/RamyHakam/multi-tenancy-project-example
๐ License
MIT ยฉ Ramy Hakam