<?php
use Illuminate\Database\Capsule\Manager;
use Illuminate\Container\Container;
$config = [
'driver' => 'mysql',
'host' => 'notlocalhost',
'database' => 'my_db',
'username' => 'notroot',
'password' => 'supersecret',
'collation' => 'utf8_unicode_ci',
];
$container = new Container();
$capsule = new Manager($container);
$capsule->addConnection($config, 'default');
// Working with Capsule
$result = $capsule->getConnection()
->table('test')
->where('id', '=', 3)
->get();
dump($result);
// Set this Capsule instance as global instance
$capsule->setAsGlobal();
$result = $capsule->table('test')
->where('id', '=', 1)
->get();
dump($result);