Download the PHP package acdphp/laravel-multitenancy without Composer

On this page you can find all versions of the php package acdphp/laravel-multitenancy. 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 laravel-multitenancy

Laravel Multitenancy

Latest Stable Version

Laravel multi-tenancy model scoping and automatic tenancy assignment.

Installation

Configuration

Publish config

Change the column name to look for tenancy in models.

By default, the tenant id is automatically resolved using the authenticated user's tenant ref key defined above. You can disable this and define your own resolver logic in AppServiceProvider or any service provider.

By default, the tenant id is automatically assigned during creation using the resolved tenancy defined above. You can disable this and manually set tenant id as you normally would.

Example Usage

Per-model column name override

The tenant_ref_key config defines the column name globally. You can override it for a specific model by defining the $tenantRefKey property. This affects auto-assignment on creation and all scoping queries for that model.

Scoping from parent relationship

Custom tenant scope condition

When a model's tenancy is more than a simple column match (e.g. tenant-owned or public), define an applyTenantScope method with your own condition. The package uses it in place of the default tenant key filter — everything else (scope bypass, the missing-tenant case, auto-assignment on creation) is still handled for you before it runs.

Models scoping from a parent relationship apply the parent's custom condition automatically:

Note: since the tenancy of such a model is defined by the condition rather than a single column, the tenant ref key is not auto-appended to $fillable. If the model has no tenant column at all, also disable auto-assignment with protected bool $autoAssignTenantId = false;.


Manually setting the tenant

In the registration, for example, tenancy isn't set because it's a non-authenticated endpoint. The tenant has to be manually assigned.

Custom Scoping Tenant ID

By default, the scoping uses the resolved tenant ID. You can set a custom scoping tenant ID resolver that supports a single value or an array of IDs.

Bypassing Scope

Sometimes, it's needed to bypass scoping when accessing a model that belongs to a tenant.

Or by using the middleware.

To re-enable scoping after bypassing:

Bypassing Automatic Tenancy Assignment

It's also possible to bypass auto-tenancy assignments.

Or by using the middleware.

To re-enable auto-assignment after bypassing:


Testing

Linting and static analysis

Lint Fix


License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-multitenancy with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/database Version ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
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 acdphp/laravel-multitenancy contains the following files

Loading the files please wait ...