mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
44 lines
1 KiB
PHP
44 lines
1 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 = array(
|
|
'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') ?: '';
|
|
|
|
$factory = new \RandomLib\Factory;
|
|
$generator = $factory->getMediumStrengthGenerator();
|
|
|
|
$container = new Container(
|
|
$db,
|
|
$generator,
|
|
'https://' . $host,
|
|
$parserUrl,
|
|
$storeRoot,
|
|
$storeHost,
|
|
$appRoot,
|
|
$editKey
|
|
);
|
|
|
|
return $container;
|