Download the PHP package asseco-voice/laravel-multitenancy without Composer

On this page you can find all versions of the php package asseco-voice/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

Multitenancy

Purpose of this repository is to enable multitenancy with multiple DB setup.

Installation

Require the package with composer require asseco-voice/laravel-multitenancy. Service provider will be registered automatically.

Setup

DB setup

Since this is a multi-DB tenancy package be sure to provide separate env values for landlord connection as well as connection for tenants.

Landlord is a separate DB connection which holds all shared migrations. The main one given through the package is tenants table which will hold configuration for all the tenants in the system. Add Landlord env variables (format is the same as native DB connection):

Use native DB connection to provide connection for tenants but comment out DB_DATABASE as this will be dynamically switched during runtime.

This means that all the tenants will be on a single connection but on separate databases. If you want to provide custom connection for some (or all) tenants, you can do so by providing that config within a DB table. More on that later.

Tenant aware commands

Some native Artisan commands are modified to provide two additional options:

Commands currently available are:

Migrations

Publish the migration by running:

php artisan vendor:publish --tag="asseco-multitenancy-migrations"

This will create a single migration within a migrations/landlord directory. Landlord represents a shared set of migrations which should be accessible independently of a chosen Tenant.

The default migration (tenants table) should hold all data related to tenants in the system. You are free to add other migrations there which would represent a shared set of tables across all tenants.

Migrate landlord files by running php artisan migrate --landlord

Once you have a tenants table, you can add a new tenant by manually filling out the DB or using Tinker (TODO: API + auto create). At that point, be sure to also create the database you specified in the table.

Example:

Be sure that foo database exists on the server you defined within .env. At the point you hit foo.localhost, you will see the tenant switch to that particular DB.

Separate tenant connections

To provide a tenant with a completely custom DB connection edit its configuration in DB by filling out all the db_ values in the tenants table. If one of the values is missing from the configuration, default will be used. Rest of the values will in that case be ignored.

Extending the package

Publish the configuration file by running:

php artisan vendor:publish --tag="asseco-multitenancy-config"

Extensible parts:

Final notes

Due to our specific use cases, this package was created as a merge of these 2 amazing multi tenancy packages:


All versions of laravel-multitenancy with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
laravel/framework Version ^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 asseco-voice/laravel-multitenancy contains the following files

Loading the files please wait ....