diff --git a/backend/config/database.php b/backend/config/database.php new file mode 100644 index 0000000..06a2816 --- /dev/null +++ b/backend/config/database.php @@ -0,0 +1,20 @@ +addConnection([ + 'driver' => 'pgsql', + 'host' => $_ENV['DB_HOST'], + 'port' => $_ENV['DB_PORT'], + 'database' => $_ENV['DB_NAME'], + 'username' => $_ENV['DB_USER'], + 'password' => $_ENV['DB_PASSWORD'], + 'charset' => 'utf8', +]); + +$capsule->setAsGlobal(); +$capsule->bootEloquent(); + +return $capsule; diff --git a/backend/public/index.php b/backend/public/index.php index 0209daf..f2c5154 100644 --- a/backend/public/index.php +++ b/backend/public/index.php @@ -6,14 +6,19 @@ use Slim\App; (static function (): void { $root = dirname(__DIR__); - require $root.'/vendor/autoload.php'; + require $root . '/vendor/autoload.php'; - $container = require $root.'/config/container.php'; + $dotenv = Dotenv\Dotenv::createImmutable($root); + $dotenv->safeLoad(); + + require $root . '/config/database.php'; + + $container = require $root . '/config/container.php'; /** @var App $app */ $app = Bridge::create($container); - (require $root.'/config/routes.php')($app); + (require $root . '/config/routes.php')($app); $app->run(); })();