Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Multitenancy Laravel Package

romegadigital/multitenancy

A simple multi-tenancy package for Laravel that scopes Eloquent models to the current tenant using a tenant_id column and global scopes. Includes middleware for tenant resolution, a Tenant model, and tenant-aware helpers for isolating data in a single database.

Deep Wiki
Context7

Technical Evaluation

Architecture fit. The package is deliberately narrow: subdomain-based tenant resolution wired into Laravel's routing/middleware stack. That is a good fit only if the product's tenancy boundary is genuinely "one codebase, one deployment, tenant identified by host." It is unlikely to be a good fit if the architecture requires database-per-tenant isolation, schema-per-tenant, per-tenant queues/storage/cache, or tenant-aware console and scheduled commands — a "simple and opinionated" package usually implements the routing/resolution layer well and treats the rest as the application's problem. Before anything else, the tenancy isolation model must be decided at the product level, because this package constrains it.

Integration feasibility. MIT-licensed, small surface area, Composer-installable, so the mechanical integration is low-cost. The real constraint is the release history: last release 2023-05-31 and the repository is archived. That places it around the Laravel 10 era; any current Laravel application will require loosening version constraints, a fork, and manual compatibility validation. This is feasible but reframes the package from dependency to vendored component we own. For a small, readable codebase that is a real but manageable cost; it must be priced in explicitly rather than discovered later.

Technical risk. Archived status is the dominant risk and it is not a "someday" risk — it is a present-tense risk. There is no security patching path, no CVE response, and no upgrade support. Tenant isolation is the highest-severity failure class in a multi-tenant SaaS: a bug here is a cross-customer data breach, not a UI defect. Assigning that boundary to an unmaintained component with 374 stars and a low maturity score is a defensible choice only with compensating controls (full source review, fork ownership, and automated cross-tenant leakage tests in CI). Secondary risks: undocumented behavior around tenant context propagation to jobs, events, and notifications; host-header/subdomain spoofing if resolution is not hardened; and lock-in to an opinionated routing convention that is awkward to unwind once it is baked into the domain model.

Key questions.

  • What is the actual isolation model — shared database with query scoping, or separate databases? Scoping is materially weaker and demands stricter review.
  • Which Laravel and PHP versions are supported, and which of those still receive security patches?
  • Does tenant context propagate to queues, scheduled commands, events, cache, sessions, and filesystem, or is only the HTTP path covered?
  • How is tenant resolution hardened against spoofed Host headers and unknown subdomains?
  • Is the maintainer reachable for a fork/transfer conversation, or is the source effectively orphaned?
  • What does a full read of the source reveal about test coverage, particularly negative-path and cross-tenant tests?

Integration Approach

Stack fit. Appropriate for a greenfield or early-stage Laravel product where subdomain tenancy is the intended UX and where the team accepts ownership of the component. Inappropriate for regulated workloads, enterprise contracts with isolation commitments, or any platform where a tenancy bug would be a reportable incident — the maintenance posture alone disqualifies it there regardless of code quality.

Migration path. Two viable paths, and the decision should be made before tenancy primitives leak into the domain model. Path A: adopt by forking into the repository, pinning the fork, and treating it as first-party code. Path B: evaluate against a maintained alternative (e.g. stancl/tenancy or spatie/laravel-multitenancy) during the spike and adopt whichever fits the isolation model. The cost of Path B rises sharply once routing, models, and jobs assume this package's conventions, so run the comparison up front rather than as a later optimization.

Compatibility. Validate concretely, not by reading the README: Laravel and PHP version constraints, PHPUnit/Pest versions, middleware priority ordering against existing global middleware, interaction with localization, route model binding, and signed URLs. Confirm behavior for subdomains that do not map to a tenant, and for the apex/www host. If per-tenant databases are in scope, verify connection pooling and migration execution per tenant under load.

Sequencing.

  1. Decide the isolation model and write it down as an architectural decision record.
  2. Timebox a spike (1–2 days) using a real slice of the application, not a toy CRUD.
  3. Make the adopt / fork / replace decision with a named owner attached to whichever option wins.
  4. Establish cross-tenant leakage tests in CI before building tenant-scoped features — these are the regression net that substitutes for upstream maintenance.
  5. Only then build features, keeping tenancy assumptions isolated behind a thin internal abstraction so replacement remains a bounded change.

Operational Impact

Maintenance. This is the crux. Archived means no upstream maintenance at all; the organization inherits 100% of it, including Laravel major-version bumps, PHP deprecations, and any security fix. Mitigating factor: the package is small and opinionated, so the source is likely reviewable in an afternoon and patchable by one competent Laravel engineer. Budget a recurring allocation — realistically a small number of engineer-days per Laravel major release — rather than assuming zero.

Support. Community-only and now frozen. GitHub issues and PRs are not a support channel. Internal documentation and a named internal owner are mandatory; if the owning engineer leaves, the tenancy boundary becomes an undocumented liability. Do not let external docs be the only reference, because they will rot against current Laravel versions.

Scaling. HTTP-layer subdomain resolution scales comfortably — it is cheap and cacheable. The scaling pressure points sit around it: wildcard TLS certificate management (or per-tenant certificates and DNS automation), tenant-resolution caching to avoid a lookup per request, connection count if per-tenant databases are used, and any per-tenant provisioning workflow. None of these are solved by a routing-focused package; they are operational capabilities the team must build regardless of which tenancy library is chosen.

Failure modes. Rank by blast radius: (1) cross-tenant data leakage from missed scoping on a query, job, or export; (2) tenant context lost in queued jobs, scheduled tasks, notifications, or event listeners, causing writes to the wrong tenant; (3) subdomain/host-header spoofing leading to unauthorized tenant access; (4) incomplete teardown on tenant deletion leaving orphaned data, a compliance problem; (5) wildcard certificate expiry, which is a tenant-wide outage rather than a single-site outage. Items 1 and 2 are the ones that justify the CI leakage tests in the sequencing plan.

Ramp-up. Low for the package API — a few middleware and routing conventions. Moderate for multi-tenancy as a discipline, which is the real onboarding cost and is independent of this package. New engineers should be onboarded to the isolation model and the leakage test suite, not to the library. Given the archived status, plan for a short internal design note: what the package does, where it is patched, and what to check on every Laravel upgrade.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource