diff --git a/.gitignore b/.gitignore index 283d5b7f..b07b73d1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ vendor/ data/database.sqlite data/shlink-tests.db data/GeoLite2-City.* +data/infra/matomo docs/swagger-ui* docs/mercure.html docker-compose.override.yml diff --git a/config/config.php b/config/config.php index 9df29138..a52ade5a 100644 --- a/config/config.php +++ b/config/config.php @@ -22,33 +22,39 @@ use const PHP_SAPI; $isTestEnv = env('APP_ENV') === 'test'; $enableSwoole = PHP_SAPI === 'cli' && openswooleIsInstalled() && ! runningInRoadRunner(); -return (new ConfigAggregator\ConfigAggregator([ - ! $isTestEnv - ? new EnvVarLoaderProvider('config/params/generated_config.php', enumValues(Core\Config\EnvVars::class)) - : new ConfigAggregator\ArrayProvider([]), - Mezzio\ConfigProvider::class, - Mezzio\Router\ConfigProvider::class, - Mezzio\Router\FastRouteRouter\ConfigProvider::class, - $enableSwoole && class_exists(Swoole\ConfigProvider::class) - ? Swoole\ConfigProvider::class - : new ConfigAggregator\ArrayProvider([]), - ProblemDetails\ConfigProvider::class, - Diactoros\ConfigProvider::class, - Common\ConfigProvider::class, - Config\ConfigProvider::class, - Importer\ConfigProvider::class, - IpGeolocation\ConfigProvider::class, - EventDispatcher\ConfigProvider::class, - Core\ConfigProvider::class, - CLI\ConfigProvider::class, - Rest\ConfigProvider::class, - 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'), - // Routes have to be loaded last - new ConfigAggregator\PhpFileProvider('config/autoload/routes.config.php'), -], 'data/cache/app_config.php', [ - Core\Config\PostProcessor\BasePathPrefixer::class, - Core\Config\PostProcessor\MultiSegmentSlugProcessor::class, - Core\Config\PostProcessor\ShortUrlMethodsProcessor::class, -]))->getMergedConfig(); +return (new ConfigAggregator\ConfigAggregator( + providers: [ + ! $isTestEnv + ? new EnvVarLoaderProvider('config/params/generated_config.php', enumValues(Core\Config\EnvVars::class)) + : new ConfigAggregator\ArrayProvider([]), + Mezzio\ConfigProvider::class, + Mezzio\Router\ConfigProvider::class, + Mezzio\Router\FastRouteRouter\ConfigProvider::class, + $enableSwoole && class_exists(Swoole\ConfigProvider::class) + ? Swoole\ConfigProvider::class + : new ConfigAggregator\ArrayProvider([]), + ProblemDetails\ConfigProvider::class, + Diactoros\ConfigProvider::class, + Common\ConfigProvider::class, + Config\ConfigProvider::class, + Importer\ConfigProvider::class, + IpGeolocation\ConfigProvider::class, + EventDispatcher\ConfigProvider::class, + Core\ConfigProvider::class, + CLI\ConfigProvider::class, + Rest\ConfigProvider::class, + 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', + ), + // Routes have to be loaded last + new ConfigAggregator\PhpFileProvider('config/autoload/routes.config.php'), + ], + cachedConfigFile: 'data/cache/app_config.php', + postProcessors: [ + Core\Config\PostProcessor\BasePathPrefixer::class, + Core\Config\PostProcessor\MultiSegmentSlugProcessor::class, + Core\Config\PostProcessor\ShortUrlMethodsProcessor::class, + ], +))->getMergedConfig(); diff --git a/docker-compose.yml b/docker-compose.yml index a398d4bc..014764f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,6 +33,7 @@ services: - shlink_mercure - shlink_mercure_proxy - shlink_rabbitmq + - shlink_matomo environment: LC_ALL: C extra_hosts: @@ -70,6 +71,7 @@ services: - shlink_mercure - shlink_mercure_proxy - shlink_rabbitmq + - shlink_matomo environment: LC_ALL: C extra_hosts: @@ -95,6 +97,7 @@ services: - shlink_mercure - shlink_mercure_proxy - shlink_rabbitmq + - shlink_matomo environment: LC_ALL: C extra_hosts: @@ -201,3 +204,21 @@ services: - "8005:8080" volumes: - ./docs/swagger:/app + + shlink_matomo: + container_name: shlink_matomo + image: matomo:4.14-apache + ports: + - "8003:80" + volumes: + # Matomo does not persist port in trusted hosts. This is needed to edit config afterwards + # https://github.com/matomo-org/matomo/issues/9549 + - ./data/infra/matomo:/var/www/html + links: + - shlink_db_mysql + environment: + MATOMO_DATABASE_HOST: "shlink_db_mysql" + MATOMO_DATABASE_ADAPTER: "mysql" + MATOMO_DATABASE_DBNAME: "matomo" + MATOMO_DATABASE_USERNAME: "root" + MATOMO_DATABASE_PASSWORD: "root"