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