2016-04-10 10:38:07 +03:00
|
|
|
<?php
|
2019-10-05 18:26:10 +03:00
|
|
|
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-09-29 10:52:32 +03:00
|
|
|
namespace Shlinkio\Shlink;
|
|
|
|
|
2020-01-01 23:11:53 +03:00
|
|
|
use Laminas\ConfigAggregator;
|
2020-10-16 20:21:40 +03:00
|
|
|
use Laminas\Diactoros;
|
2020-01-01 23:11:53 +03:00
|
|
|
use Mezzio;
|
|
|
|
use Mezzio\ProblemDetails;
|
2021-08-07 12:05:20 +03:00
|
|
|
use Mezzio\Swoole;
|
2022-01-15 18:06:24 +03:00
|
|
|
use Shlinkio\Shlink\Config\ConfigAggregator\EnvVarLoaderProvider;
|
2019-07-19 20:54:39 +03:00
|
|
|
|
2021-02-13 19:48:03 +03:00
|
|
|
use function class_exists;
|
2022-01-04 19:50:41 +03:00
|
|
|
use function Shlinkio\Shlink\Config\env;
|
2022-08-21 14:19:27 +03:00
|
|
|
use function Shlinkio\Shlink\Config\swooleIsInstalled;
|
2016-04-10 10:38:07 +03:00
|
|
|
|
2021-12-06 19:15:19 +03:00
|
|
|
use const PHP_SAPI;
|
|
|
|
|
2022-08-21 14:19:27 +03:00
|
|
|
$enableSwoole = PHP_SAPI === 'cli' && swooleIsInstalled();
|
2022-01-15 13:34:17 +03:00
|
|
|
$isTestEnv = env('APP_ENV') === 'test';
|
2021-12-06 19:15:19 +03:00
|
|
|
|
2017-03-24 22:34:18 +03:00
|
|
|
return (new ConfigAggregator\ConfigAggregator([
|
2022-01-15 13:34:17 +03:00
|
|
|
! $isTestEnv
|
2022-08-08 20:23:16 +03:00
|
|
|
? new EnvVarLoaderProvider('config/params/generated_config.php', Core\Config\EnvVars::values())
|
2022-01-15 13:34:17 +03:00
|
|
|
: new ConfigAggregator\ArrayProvider([]),
|
2020-01-01 23:11:53 +03:00
|
|
|
Mezzio\ConfigProvider::class,
|
|
|
|
Mezzio\Router\ConfigProvider::class,
|
|
|
|
Mezzio\Router\FastRouteRouter\ConfigProvider::class,
|
2022-08-21 14:19:27 +03:00
|
|
|
$enableSwoole && class_exists(Swoole\ConfigProvider::class)
|
2021-12-06 19:15:19 +03:00
|
|
|
? Swoole\ConfigProvider::class
|
|
|
|
: new ConfigAggregator\ArrayProvider([]),
|
2019-11-22 21:49:14 +03:00
|
|
|
ProblemDetails\ConfigProvider::class,
|
2020-10-16 20:21:40 +03:00
|
|
|
Diactoros\ConfigProvider::class,
|
2016-07-20 00:35:47 +03:00
|
|
|
Common\ConfigProvider::class,
|
2020-03-14 21:24:21 +03:00
|
|
|
Config\ConfigProvider::class,
|
2020-10-22 19:12:22 +03:00
|
|
|
Importer\ConfigProvider::class,
|
2019-08-10 14:42:37 +03:00
|
|
|
IpGeolocation\ConfigProvider::class,
|
2020-03-14 21:24:21 +03:00
|
|
|
EventDispatcher\ConfigProvider::class,
|
2022-08-03 20:32:59 +03:00
|
|
|
Core\ConfigProvider::class,
|
2022-08-04 12:14:26 +03:00
|
|
|
CLI\ConfigProvider::class,
|
|
|
|
Rest\ConfigProvider::class,
|
2018-12-07 22:42:58 +03:00
|
|
|
new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
|
2022-01-15 13:34:17 +03:00
|
|
|
$isTestEnv
|
2019-01-26 11:09:49 +03:00
|
|
|
? new ConfigAggregator\PhpFileProvider('config/test/*.global.php')
|
2022-01-15 13:34:17 +03:00
|
|
|
: new ConfigAggregator\ArrayProvider([]),
|
2022-08-04 12:14:26 +03:00
|
|
|
// Routes have to be loaded last
|
|
|
|
new ConfigAggregator\PhpFileProvider('config/autoload/routes.config.php'),
|
2019-04-18 11:37:38 +03:00
|
|
|
], 'data/cache/app_config.php', [
|
2019-09-13 21:03:53 +03:00
|
|
|
Core\Config\BasePathPrefixer::class,
|
2022-08-06 10:30:13 +03:00
|
|
|
Core\Config\MultiSegmentSlugProcessor::class,
|
2019-04-18 11:37:38 +03:00
|
|
|
]))->getMergedConfig();
|