Download the PHP package quantumtecnology/multi-tenant without Composer

On this page you can find all versions of the php package quantumtecnology/multi-tenant. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package multi-tenant

Laravel Multi-Tenant (QuantumTecnology\Tenant)

A small, flexible Laravel package to manage multi-tenant applications. It lets you switch the application context to a specific tenant, connect to its database using pluggable strategies, and optionally apply environment side-effects (like cache prefixes). The package also provides a convenient command to run tenant migrations per tenant, either synchronously or via queued batch jobs with automatic rollback on failures.

Features

Installation

Install via Composer:

The service provider is auto-discovered:

Publishing

Publish the configuration file:

This will create config/tenant.php in your application.

Publish the baseline migrations provided by the package:

This will publish:

Configuration (config/tenant.php)

Key options you can tweak:

Note: Ensure your database.default is a central connection. The package dynamically registers a separate connection for the active tenant when switching context.

How it works

Accessing the current tenant

Use the helper:

Or resolve directly from the container:

Switching to a specific tenant (programmatically)

You can manually define the active tenant anywhere in your app using the TenantManager. This will reconfigure the database connection for the tenant and apply environment side-effects (like cache prefixes).

Notes:

Identifying tenant via middleware

You can identify and switch to the correct tenant per request using a middleware in your application. Below is a simple example that supports subdomain, header, or route parameter identification.

Middleware example (App\Http\Middleware\IdentifyTenantMiddleware.php):

Register the middleware in app/Http/Kernel.php:

Apply the middleware to routes:

Notes:

Running tenant migrations

Command:

Execution mode:

Batch behavior:

Extensibility

You can fully customize how tenant connections are established and how environment changes are applied by binding your own implementations to these contracts:

Example: Custom connection resolver

Register your resolver (e.g. in a service provider registered after the package provider):

Similarly, you can replace the environment applier to add custom behavior during switch and reset.

Tenant model

The default model QuantumTecnology\Tenant\Models\Tenant:

You can swap this model via config('tenant.model.tenant') with your own App\Models\Tenant.

Queue propagation

The package attaches the current tenant_id to the queue payload when jobs are dispatched. Before processing a job, the package will re-apply the tenant context automatically so your jobs run within the correct tenant connection and environment.

Local testing & development

Version compatibility

License

MIT License. See LICENSE file if present. © Contributors.

Credits

Queue configuration and central pinning

This package ensures that jobs are always enqueued and stored in the central database connection, regardless of the active tenant at dispatch time. This avoids issues where switching database.default to a tenant would cause the database queue driver to write to a tenant DB that lacks jobs/job_batches/failed_jobs tables.

What the package does:

Operational requirements:

Environment variables you may use:

These envs are optional; the package defaults to the central connection even without them.

Helpers

Example:

Model utilities

For models that must always use the central connection, you can use the provided trait:

Service provider behaviors

Configuration reference (contracts and swappable parts)

You can override bindings to customize behavior:

Bind your implementations via a service provider using singletonIf/singleton.

Troubleshooting


All versions of multi-tenant with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/container Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
stancl/virtualcolumn Version ^1.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package quantumtecnology/multi-tenant contains the following files

Loading the files please wait ...