mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Demostf\API\Container;
|
|
|
|
$autoloader = require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
if (!getenv('DB_TYPE')) {
|
|
Dotenv::load(__DIR__ . '/../');
|
|
}
|
|
|
|
$connectionParams = [
|
|
'dbname' => getenv('DB_DATABASE'),
|
|
'user' => getenv('DB_USERNAME'),
|
|
'password' => getenv('DB_PASSWORD'),
|
|
'host' => getenv('DB_HOST'),
|
|
'port' => getenv('DB_PORT'),
|
|
'driver' => getenv('DB_TYPE'),
|
|
];
|
|
if ($connectionParams['driver'] === 'pgsql') {
|
|
$connectionParams['driver'] = 'pdo_pgsql';
|
|
}
|
|
$db = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
|
|
$host = getenv('BASE_HOST') ?: '';
|
|
$storeRoot = getenv('DEMO_ROOT') ?: '';
|
|
$storeHost = getenv('DEMO_HOST') ?: '';
|
|
$parserUrl = getenv('PARSER_URL') ?: '';
|
|
$appRoot = getenv('APP_ROOT') ?: '';
|
|
$editKey = getenv('EDIT_SECRET') ?: '';
|
|
$uploadKey = getenv('UPLOAD_KEY') ?: '';
|
|
|
|
$factory = new \RandomLib\Factory();
|
|
$generator = $factory->getMediumStrengthGenerator();
|
|
|
|
$container = new Container(
|
|
Flight::request(),
|
|
Flight::response(),
|
|
$db,
|
|
$generator,
|
|
'https://' . $host,
|
|
$parserUrl,
|
|
$storeRoot,
|
|
$storeHost,
|
|
$appRoot,
|
|
$editKey,
|
|
$uploadKey
|
|
);
|
|
|
|
return $container;
|