Download the PHP package sbine/simple-tenancy without Composer

On this page you can find all versions of the php package sbine/simple-tenancy. 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 simple-tenancy

Simple Laravel Multi-Tenancy

Build status

Simple Tenancy adds automatic multi-tenant support to Eloquent models stored in a shared database.

It requires zero configuration in most cases, relying on established Laravel conventions and a single column on each table.

How it works

Under the hood, it has only 4 components:

  1. Tenant: Keeps track of the current user
  2. HasTenancy: A trait for models belonging to the tenant, which registers:
  3. TenancyScope: A global scope limiting all the model's queries to the current tenant
  4. TenancyObserver: An observer which sets the current tenant column/identifier on save

By default, the tenant is Laravel's Auth::user(), and all tenancy checks are disabled when no one is authenticated.

Installation

  1. Install using Composer:

  2. Add the HasTenancy trait to all models belonging to the tenant:

  3. Ensure a user_id column exists on the table of every model using the trait.

Customizing the tenant column/ID

If needed, you can customize the name of the tenant column or identifier by extending the Tenant class and binding it into the container:

Customizing tenancy behavior

By default, if no user is authenticated tenancy will be completely disabled. This is by design so the library doesn't interfere with testing, seeding, and other unauthenticated model usage.

To change the tenancy behavior in any way, you can override the Tenant binding in the application container.

For example, to prevent all querying and saving of tenant models when no one is authenticated:

To allow overriding tenancy checks based on a policy or method, pass a callback returning true or false:

For complete control over tenant behavior, you can bind your own Tenant implementation:

Disabling tenancy

For convenience, a SuperAdmin class is provided which you can bind at any time to disable tenant checks:


All versions of simple-tenancy with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
laravel/framework Version ^7.0 || ^8.0 || ^9.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 sbine/simple-tenancy contains the following files

Loading the files please wait ....