1. Go to this page and download the library: Download rolice/laravel-db-switch library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/*
* Package Service Providers...
*/
Rolice\LaravelDbSwitch\DbSwitchServiceProvider::class,
/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's servipoce providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not
/*
|--------------------------------------------------------------------------
| Register Facades
|--------------------------------------------------------------------------
|
| A config section for registering facades through class aliases.
|
*/
class_alias(\Rolice\LaravelDbSwitch\Facades\DbSwitch::class, 'DbSwitch');
// Usage through the facade - DbSwitch
DbSwitch::to('my-cool-db'); // The defaut connection
DbSwitch::connectionTo('my-cool-conenction', 'my-cool-db'); // A specific connection database
// Usage through the Laravel Service Container (IoC)
app('db.switch')->to('my-cool-db'); // The defaut connection
app('db.switch')->connectionTo('my-cool-conenction', 'my-cool-db'); // A specific connection database
sh
php /path/to/composer.phar install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.