You can use the Container object as repository handler.
This requires the Container component.
use Fist\Database\Database;
use Fist\Container\Container;
use Fist\Repository\ContainerRepository;
$container = new Container();
// The below two lines are not needed, unless you wish to change the default values.
//$container->instance('default.driver', 'mysql');
//$container->instance('default.connection', 'default');
// Method A: You register your connections directly to the container instance (can be done at anytime)
//$container->instance('connections.default', [
// 'driver' => 'mysql',
// 'hostname' => '127.0.0.1',
// 'database' => 'database',
// 'username' => 'root',
// 'password' => '',
// 'prefix' => '',
//]);
// Those below lines are not needed unless you whish to overwrite some connection drivers
//$connection->bind('drivers.mysql', \Fist\Database\Connectors\MysqlConnection::class);
//$connection->bind('drivers.sqlite', \Fist\Database\Connectors\SqliteConnection::class);
$repository = new ContainerRepository($container);
// Method B: You register your connections to the repository (can be done at any time)
//$repository->set('connections.default', [
// 'driver' => 'mysql',
// 'hostname' => '127.0.0.1',
// 'database' => 'database',
// 'username' => 'root',
// 'password' => '',
// 'prefix' => '',
//]);
$database = new Database($repository);
// Method C: You register your connections to the database object (can be done at any time) (recommened)
$database->addConnection('default', [
'driver' => 'mysql',
'hostname' => '127.0.0.1',
'database' => 'database',
'username' => 'root',
'password' => '',
'prefix' => '',
]);
// For changing the default driver
//$database->setDefaultDriver('mysql');
// For changing the default connection
//$database->setDefaultConnection('default');