container.php 768 B

123456789101112131415161718192021222324252627
  1. <?php
  2. declare(strict_types=1);
  3. use Laminas\ServiceManager\ServiceManager;
  4. use Symfony\Component\Lock;
  5. use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY;
  6. chdir(dirname(__DIR__));
  7. require 'vendor/autoload.php';
  8. // This class alias tricks the ConfigAbstractFactory to return Lock\Factory instances even with a different service name
  9. // It needs to be placed here as individual config files will not be loaded once config is cached
  10. if (! class_exists(LOCAL_LOCK_FACTORY)) {
  11. class_alias(Lock\LockFactory::class, LOCAL_LOCK_FACTORY);
  12. }
  13. // Build container
  14. return (function () {
  15. $config = require __DIR__ . '/config.php';
  16. $container = new ServiceManager($config['dependencies']);
  17. $container->setService('config', $config);
  18. return $container;
  19. })();