diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php index aa105e6d..cda3aeea 100644 --- a/config/autoload/dependencies.global.php +++ b/config/autoload/dependencies.global.php @@ -23,6 +23,12 @@ return [ Container\ApplicationConfigInjectionDelegator::class, ], ], + + 'lazy_services' => [ + 'proxies_target_dir' => 'data/proxies', + 'proxies_namespace' => 'ShlinkProxy', + 'write_proxy_files' => true, + ], ], ]; diff --git a/config/autoload/dependencies.local.php.dist b/config/autoload/dependencies.local.php.dist new file mode 100644 index 00000000..5ce9874b --- /dev/null +++ b/config/autoload/dependencies.local.php.dist @@ -0,0 +1,12 @@ + [ + 'lazy_services' => [ + 'write_proxy_files' => false, + ], + ], + +]; diff --git a/module/Common/config/dependencies.config.php b/module/Common/config/dependencies.config.php index 8ac6311b..a43d1e5c 100644 --- a/module/Common/config/dependencies.config.php +++ b/module/Common/config/dependencies.config.php @@ -14,6 +14,7 @@ use Symfony\Component\Filesystem\Filesystem; use Zend\I18n\Translator\Translator; use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory; use Zend\ServiceManager\Factory\InvokableFactory; +use Zend\ServiceManager\Proxy\LazyServiceFactory; return [ @@ -56,6 +57,19 @@ return [ 'abstract_factories' => [ Factory\DottedAccessConfigAbstractFactory::class, ], + 'delegators' => [ + // The GeoLite2 db reader has to be lazy so that it does not try to load the DB file at app bootstrapping. + // By doing so, it would fail the first time shlink tries to download it. + Reader::class => [ + LazyServiceFactory::class, + ], + ], + + 'lazy_services' => [ + 'class_map' => [ + Reader::class => Reader::class, + ], + ], ], ConfigAbstractFactory::class => [