Download the PHP package vivait/tenant-bundle without Composer
On this page you can find all versions of the php package vivait/tenant-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tenant-bundle
TenantBundle

Allows separate Symfony environments per tenant
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding the following line in the app/AppKernel.php
file of your project:
Step 3: Altering your kernel to be tenanted
Because a kernel environment is immutable, we need to decipher the tenant before booting the kernel. We have created a tenanted kernel for your AppKernel to extend, which acts as a middleware to Symfony's Kernel. When using this middleware, you will need to implement a couple of methods.
The first abstract method, is used to return an array of Tenant objects. A number of providers are provided, although this could also implement custom logic, if needed.
The second abstract method, is used to locate the current tenant, so the kernel can alter the environment based on this. A number of locators are provided, although this could also implement custom logic, if needed.
Below is an example of the implementation of both of these, and if you're unsure what any of this means, is an advised starting point:
Step 4: Creating environments for each tenant
An environment will be automatically created for each tenant by Symfony. However,
if you choose to use the default
method, as provided by Symfony, then you will need to create a new config file for
each tenant environment. Each tenant environment is prefixed with 'tenant_', so if
you have a tenant called 'mytenant', then you'd need to create
'app/config/config_tenant_mytenant.yml'
. You can configure this behaviour by
changing your method, but you will
also need to customise the patterns used in ConfigProvider to match the change in
config structure.
You could also use an alternative provider to provide a list of tenants, for example there is a YamlProvider that retrieves a list of tenants from a YAML file.
Running commands against tenants
Since each tenant now runs under a separate environment, when updating your application
you'll need to run commands such as cache clear or doctrine migrations against
each tenant's environment. A special binary has been provided to make this easier and
is used by simply prefixing your usual command with the tenant
binary:
This will automatically run the cache clear command against all tenants.
Parallel commands & daemons
If you want to run a command in parallel, for example a daemon command, then you can
specify this using the -P
option:
In the example above, this will run the cache clear command for up to 10 tenants in parallel.
If you specify -P
as 0 then the binary will automatically set the number of processes to
match the number of tenants.
Specifying specific tenants
You can specify specific tenants to run commands against using the -t
option:
Other options
You can get a full list of options using -h: