PHPackages                             techsemicolon/laravel-dynamic-user-connection - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. techsemicolon/laravel-dynamic-user-connection

ActiveLibrary[Database &amp; ORM](/categories/database)

techsemicolon/laravel-dynamic-user-connection
=============================================

A laravel package to dynamically have separate database connection setup for each user.

2.0.0(7y ago)3200MITPHPPHP &gt;=5.4.0

Since Feb 4Pushed 7y agoCompare

[ Source](https://github.com/techsemicolon/laravel-dynamic-user-connection)[ Packagist](https://packagist.org/packages/techsemicolon/laravel-dynamic-user-connection)[ RSS](/packages/techsemicolon-laravel-dynamic-user-connection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

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 :
--------------

[](#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 :
--------------

[](#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 :
-------

[](#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 :

```
