hakam/multi-tenancy-bundle
Hakam Multi-Tenancy Bundle is a Laravel package for adding multi-tenant support with tenant-aware database connections, migrations, and configuration, helping isolate tenant data and simplify managing multiple tenants in one application.
Architecture fit — poor as-is, instructive as a reference. The package is a Symfony bundle (hakam/multi-tenancy-bundle), which is structurally incompatible with a Laravel application. Symfony bundles ship a Bundle subclass, a DI Extension, compiler passes, and event subscribers wired through the Symfony kernel; Laravel has no equivalent loading mechanism. Laravel's analogues are service providers, middleware, and container bindings. Adopting this package in a Laravel codebase is not a configuration exercise — it is a rewrite of the integration layer, and probably of the package internals.
What does transfer is the domain model. Multi-tenancy decomposes into the same concerns in either framework: tenant resolution (domain, subdomain, header, path), tenant identification and caching, connection/DB switching, and isolation of cross-cutting state (cache, filesystem, queue, sessions, config, logs). This bundle can serve as a design reference and a checklist for what a Laravel implementation must cover, particularly around connection lifecycle and per-request tenant context.
Integration feasibility — low for direct dependency, moderate for conceptual reuse. Directly requiring this package in a Laravel app yields nothing loadable and adds a dormant dependency with supply-chain surface and no runtime value. A shim (porting the bundle's services into service providers) is feasible but only rational if the bundle's tenancy logic is genuinely differentiated. Given 133 stars and 0 dependents, there is no evidence base that its design decisions have survived contact with production traffic at any scale.
Technical risk — high, concentrated in data isolation. Multi-tenancy is a security-boundary concern: a defect is not a bug, it is cross-tenant data leakage. Risk factors:
Key questions for the maintainer / spike:
Stack fit — mismatch. If the target platform is Laravel, this package is out of scope as a runtime dependency. If the organization also operates Symfony services, this bundle becomes a candidate there and should be evaluated on its own merits against those services' version constraints.
Recommended path — use as reference, not dependency. Three options, in order of preference:
| Option | Description | Verdict |
|---|---|---|
| A. Laravel-native adoption | Evaluate stancl/tenancy or spatie/laravel-multitenancy against the requirements checklist derived from this bundle |
Preferred |
| B. Reference-based in-house build | Extract the bundle's tenancy model as a spec; implement with Laravel middleware + service providers | Viable if requirements are unusual |
| C. Port the bundle | Reimplement its services as Laravel providers | Only if the bundle contains logic we cannot source elsewhere |
In all cases the bundle's value is the requirements checklist, not the code.
Compatibility. Confirm PHP version floor, Symfony major version, and whether the tenancy mechanism depends on Symfony-specific HTTP kernel events or Doctrine DBAL connection hooks. Doctrine coupling matters: if the bundle drives tenancy by swapping Doctrine connections, that logic maps to Laravel's connection resolver but not cleanly, and the mapping should be validated in a spike rather than assumed.
Sequencing.
Maintenance. Direct adoption transfers an unmaintained-risk dependency into a critical security path. Even in the reference-only path, the cost is bounded: a one-time spike plus a written spec, with no ongoing dependency obligation. This is the strongest argument for the reference approach — it captures the design value and discards the lifecycle risk.
Support. No vendor, no SLA, community-only. With 0 dependents there is no peer community to draw on for incident response. Any production issue in a directly-adopted scenario is resolved by us, against code we did not write. Budget accordingly: assume we own it from day one.
Scaling. The operational scaling characteristics that matter are tenant count, per-tenant migration and provisioning time, and connection pool pressure. A database-per-tenant model multiplies connection overhead by tenant count and makes migrations an N-step operation that must be orchestrated, idempotent, and observable. None of these concerns are solved by the bundle's abstractions alone; they are platform engineering work regardless of which implementation is chosen.
Failure modes — the ones to instrument for:
Ramp-up. The team's Laravel fluency does not transfer to a Symfony bundle — subscribers, compiler passes, and DI extension semantics are unfamiliar surface area, and debugging them adds latency to every incident. The Laravel-native alternatives cost materially less to onboard because they use primitives the team already knows. Estimated ramp-up: days for a Laravel-native package versus weeks for a Symfony bundle port, with the port also carrying permanent ownership.
Bottom line. Treat this package as an architecture reference, not a dependency. Its score and zero-dependency count do not support production adoption on a security-boundary concern, and its framework is a structural mismatch for a Laravel target. Run the requirements spike, use the bundle to pressure-test the checklist, and adopt or build on Laravel-native primitives.
How can I help you explore Laravel packages today?