Download the PHP package techsemicolon/laravel-dynamic-user-connection without Composer
On this page you can find all versions of the php package techsemicolon/laravel-dynamic-user-connection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download techsemicolon/laravel-dynamic-user-connection
More information about techsemicolon/laravel-dynamic-user-connection
Files in techsemicolon/laravel-dynamic-user-connection
Package laravel-dynamic-user-connection
Short Description A laravel package to dynamically have separate database connection setup for each user.
License MIT
Informations about the package laravel-dynamic-user-connection
Laravel dynamic user connection
If you need to have separate databases for each user, then you are on the right place. This is a laravel package which helps you setup the dynamic user database connections in just few seconds.
Installation :
composer require techsemicolon/laravel-dynamic-user-connection
Then add DynamicConnectionServiceProvider
entry in config/app.php
's providers
array :
Techsemicolon\DynamicConnection\DynamicConnectionServiceProvider::class,
How it works :
You should have basic mysql database collection which has users
table. Basic login authentication will work from there as usual.
The package comes into picture once user is logged in, and switches the database as per applicable settings in App\User.php
model.
Usage :
The package expects you to save these details in users
table. What package needs is the column name where the information for dynamic user connection is stored.
You can set database by adding following public property in App\User.php
model :
Above settings will take the string value stored in database_name
column of users
table as the database name for that user's connection.
You can optionally specify username and password columns as well :
Note : you need to decrypt() the database_password column value while storing into users
table using laravel's decrypt()
helper. This has been done as it is not safe to store passwords directly as a string in the database.
If password is not encryptable then package throws DynamicConnectionInvalidPasswordException
.
License :
This package is open-sourced software licensed under the MIT license