Download the PHP package sommer/wn-multidb-plugin without Composer

On this page you can find all versions of the php package sommer/wn-multidb-plugin. 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 wn-multidb-plugin

WinterCMS Multi Databases

WinterCMS Plugin to create SaaS applications in different databases, making it easier to manage multiple clients. To develop this plugin I reused several classes that WinterCMS itself has, trying to create the simplest code possible.

Important This plugin is still in the testing and development stages, use at your own risk.

Usage

Installation

You can install this plugin either via composer.

With Composer

Execute below at the root of your project.

Settings MultiDB - Backend

To use MultiDB you will need to follow the steps below.

Important It is necessary to have a user in the database who can Read, Edit and Update data, as well as create new databases.

Configuration .env

This is optional, but if you want to configure data from another connection in the tenants, you can put Multidb in the .env. If you don't put anything, it will automatically assume the access data from your main database server that is used in DB_*.

MultiDB Plugin

First Navigate to Settings -> MultiDB -> Settings Plugin, in this place you can configure the prefixes that the databases may have, configure what will be the names of each databases, and also, you can select which plugins will be replicated for the new created instances.

Save changes to update data

Using in PHP Code

After making the configurations mentioned above, it is necessary to edit the models of the plugins.

Trait UsesTenantConnection

This trait is responsible for managing the data that will be saved in the databases. It will be necessary to add the following trait to all models that have the replicated database, example below:

Trait UsesMainConnection

This Trait allows you to relate a table from the main database to the child database, for example, you have a Customers plugin, this plugin is using the UsesTenantConnection trait, however ou have a Core plugin that has a Country Model, this plugin you are not replicating, but you need to relate the country_id attribute of the customers table to the country table, in this situation there would be an error because MultiDB change connections momentarily, so as not to have a problem, you need to add in your model Country the trait below.

Behaviors

TenantSelectionBehavior

The TenantSelectionBehavior class added to the controller will allow the user to choose a Tenant to view once they try to access this controller (if they haven't selected one previously). At this point, this behavior adds a button next to the user's image to the navigation menu, which allows them to change the selected Tenant.

Models Helpers

Files

If in case you want to save the files in the new database, you will need to use the model Sommer\Multidb\Models\File, example use:

License

This plugin is released under the MIT License. You can freely use, modify, and distribute it in your projects, but please keep the original license intact.

Sponsors

If you find this plugin useful and would like to support its development, consider sponsoring the project. Your contributions help keep the project alive and improve its features. You can sponsor the project on GitHub Sponsors.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.


All versions of wn-multidb-plugin with dependencies

PHP Build Version
Package Version
No informations.
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 sommer/wn-multidb-plugin contains the following files

Loading the files please wait ...