This commit is contained in:
2022-06-13 21:36:52 -04:00
parent 3580738273
commit 42a97bb074
100 changed files with 2574 additions and 313 deletions

View File

@ -49,5 +49,7 @@ if (file_exists($folder)) {
$app->addRoutingMiddleware();
include_once 'databases.php';
//include_once 'databases.php';
include_once 'router.php';
return $app;

View File

@ -5,7 +5,7 @@ foreach ($database->databases as $name => $settings) {
switch (strtolower($settings->engine)) {
case 'mysql':
$dsn = "mysql:host={$settings->host->name};dbname={$settings->name}" . (isset($settings->host->port) ? ';port=' . $settings->host->port : '');
ORM::configure([
Orm::configure([
'connection_string' => $dsn,
'username' => $settings->user->name,
'password' => $settings->user->password
@ -13,12 +13,12 @@ foreach ($database->databases as $name => $settings) {
break;
}
if (isset($settings->logging) and $settings->logging) {
ORM::configure('logging', true, $name);
Orm::configure('logging', true, $name);
}
if (isset($settings->caching) and $settings->caching) {
ORM::configure('caching', true, $name);
Orm::configure('caching', true, $name);
}
}
if (isset($database->short_names) and $database->short_names) {
Model::$short_table_names = true;
Orm::$short_table_names = true;
}

View File

@ -4,6 +4,7 @@ return [
$arr = [
'default' => (object) [
'engine' => 'mysql',
'driver' => 'pdo_mysql',
'host' => (object) [
'name' => $_ENV['MYSQL_HOST'] ?? 'db'
],

View File

@ -0,0 +1,19 @@
<?php
use Psr\Container\ContainerInterface;
return [
\Doctrine\DBAL\Connection::class => function(ContainerInterface $container) {
$config = $container->get('database')->databases['default'];
$conn = [
'dbname' => $config->name,
'user' => $config->user->name,
'password' => $config->user->password,
'host' => $config->host->name,
'driver' => $config->driver
];
if (isset($config->host->port)) {
$conn['port'] = $config->host->port;
}
return \Doctrine\DBAL\DriverManager::getConnection($conn);
}
];