Download the PHP package placetopay/cerberus without Composer
On this page you can find all versions of the php package placetopay/cerberus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download placetopay/cerberus
More information about placetopay/cerberus
Files in placetopay/cerberus
Package cerberus
Short Description Allows multiple tenants on Laravel applications
License MIT
Informations about the package cerberus
Placetopay multitenancy package
This package is based on the third version of package spatie/laravel-multitenancy
.
Because it is a customization, it requires override steps mentioned below for proper installation.
More information about the package.
This package aims to standardize the configuration of the tenants
table of the landlord database, in addition to reducing the number of queries made to the same database by using cache.
Prerequsites
php8.0+
Laravel 8.0+
Installation
This package can be installed via composer:
Publishing the config file
You must publish the config file:
Publishing the migrate file
Create storage folder by tenancy
This is allowed to run only if the application has the configuration variable multitenancy.suffix_storage_path set to true.
How to use
After publish the config and migrations files, you need to create a new connection in config/database.php
,
This connection will allow the management of the landlord database, in which the tenants of the application will be stored.
The migration of the landlord table in relation to the spatie package was modified, adding a config
field of json type,
with which it's intended to centralize the configuration that is carried out in front of each tenant,
in this field you can define the connection to the database using the following structure.
You can add all configurations that you needed, this json will be convert in array dot structure and then will be set in the laravel config.
Additionally, the variable APP_IDENTIFIER
is provided in the file config/multitenancy.php
which will be the project identifier
Execute migrations
To execute the migrations of the landlord database, it's necessary to specify the connection and the path to the folder where the migrations are located: `
Jobs
You need to update the connection and tables for jobs and failed_jobs, config/queue.php
:
Storage
This package will overwrite the Storage Facade by default, setting a tenant's name as a prefix for folders that use
with Storage Facade, if you need to suffix the storage_path()
method too, you need to set to true the variable
suffix_storage_path
in config/multitenant.php
file.
How change the commands
To execute any command for one tenant you need to execute the next command structure
Addig the --tenant={tenant_domain}
flag, will be executed the commando only for the specific tenant, without this it will execute by each tenant.
translatable attributes
You can use the translate method in the tenant model to translate some keys from the config JSON.
This method uses the app locale and fallback to search the correct values from the JSON,
addionaly you should use a config/tenant.php
file to set default values for translations in case if doesn't
exist in the JSON data:
Json data from database
Default values in config/tenant.php
:
Example of use:
Clear cache remotely
Probably you need to clear the app cache when you update the tenant information,
to do this Cerberus publish a new POST route clean-cache
that you can call from another application.
this route use middleware to validate if the application can be connected, this is an example of how you need to make the request
You need to set this header in the request to clean the cache
All versions of cerberus with dependencies
ext-json Version *
spatie/laravel-multitenancy Version ^3.0
eduarguz/shift-php-cs Version ^3.0