From 50814ffd6085224aa09935d525ec030795f64f79 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 17 May 2026 21:49:42 +0300 Subject: [PATCH] wire eloquent capsule --- backend/config/database.php | 20 ++++++++++++++++++++ backend/public/index.php | 11 ++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 backend/config/database.php 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(); })();