42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Application\ApplicationFactory;
|
|
use DI\ContainerBuilder;
|
|
use Psr\Log\LoggerInterface;
|
|
use Slim\Factory\AppFactory;
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
// Load environment variables when a project .env file is present.
|
|
// Docker can provide these via env_file/environment as well; in that case
|
|
// we should not crash if the file is not mounted into the container.
|
|
$dotenvPath = __DIR__ . '/../';
|
|
if (is_file($dotenvPath . '.env')) {
|
|
$dotenv = Dotenv\Dotenv::createImmutable($dotenvPath);
|
|
$dotenv->safeLoad();
|
|
}
|
|
|
|
// Build DI container
|
|
$containerBuilder = new ContainerBuilder();
|
|
|
|
// Set up dependencies
|
|
$dependencies = require __DIR__ . '/../config/dependencies.php';
|
|
$dependencies($containerBuilder);
|
|
|
|
$container = $containerBuilder->build();
|
|
|
|
AppFactory::setContainer($container);
|
|
$app = AppFactory::create();
|
|
|
|
// Add middleware
|
|
$middleware = require __DIR__ . '/../config/middleware.php';
|
|
$middleware($app);
|
|
|
|
// Register routes
|
|
$routes = require __DIR__ . '/../config/routes.php';
|
|
$routes($app);
|
|
|
|
$app->run();
|