shlink/config/container.php

33 lines
1.1 KiB
PHP
Raw Normal View History

2016-04-10 10:52:44 +03:00
<?php
2019-10-05 18:26:10 +03:00
2017-10-12 11:13:20 +03:00
declare(strict_types=1);
2020-01-01 23:11:53 +03:00
use Laminas\ServiceManager\ServiceManager;
use Shlinkio\Shlink\Core\Config\EnvVars;
use Symfony\Component\Lock;
2016-04-10 10:52:44 +03:00
use const Shlinkio\Shlink\LOCAL_LOCK_FACTORY;
2016-04-10 13:06:28 +03:00
chdir(dirname(__DIR__));
2016-04-17 21:27:24 +03:00
require 'vendor/autoload.php';
2016-04-10 10:52:44 +03:00
2024-04-09 09:47:01 +03:00
// Set a default memory limit, but allow custom values
ini_set('memory_limit', EnvVars::MEMORY_LIMIT->loadFromEnv('512M'));
// This is one of the first files loaded. Configure the timezone here
2022-04-23 13:44:17 +03:00
date_default_timezone_set(EnvVars::TIMEZONE->loadFromEnv(date_default_timezone_get()));
2019-12-23 13:00:38 +03:00
// This class alias tricks the ConfigAbstractFactory to return Lock\Factory instances even with a different service name
// It needs to be placed here as individual config files will not be loaded once config is cached
if (! class_exists(LOCAL_LOCK_FACTORY)) {
class_alias(Lock\LockFactory::class, LOCAL_LOCK_FACTORY);
}
2019-12-23 13:00:38 +03:00
return (static function (): ServiceManager {
$config = require __DIR__ . '/config.php';
$container = new ServiceManager($config['dependencies']);
$container->setService('config', $config);
return $container;
})();