You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
728 B

5 years ago
  1. <?php
  2. /**
  3. * Initialize a dependency injection container that implemented PSR-11 and return the container.
  4. */
  5. declare(strict_types=1);
  6. /**
  7. * This file is part of Hyperf.
  8. *
  9. * @link https://www.hyperf.io
  10. * @document https://doc.hyperf.io
  11. * @contact group@hyperf.io
  12. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  13. */
  14. use Hyperf\Di\Container;
  15. use Hyperf\Di\Definition\DefinitionSourceFactory;
  16. use Hyperf\Utils\ApplicationContext;
  17. $container = new Container((new DefinitionSourceFactory(true))());
  18. if (! $container instanceof \Psr\Container\ContainerInterface) {
  19. throw new RuntimeException('The dependency injection container is invalid.');
  20. }
  21. return ApplicationContext::setContainer($container);