Container.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * This file is part of webman.
  4. *
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the MIT-LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @author walkor<[email protected]>
  10. * @copyright walkor<[email protected]>
  11. * @link http://www.workerman.net/
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace support\bootstrap;
  15. use Workerman\Worker;
  16. use Webman\Bootstrap;
  17. use Psr\Container\ContainerInterface;
  18. /**
  19. * Class Container
  20. * @package support
  21. * @method static mixed get($name)
  22. * @method static mixed make($name, array $parameters)
  23. * @method static bool has($name)
  24. */
  25. class Container implements Bootstrap
  26. {
  27. /**
  28. * @var ContainerInterface
  29. */
  30. protected static $_instance = null;
  31. /**
  32. * @param Worker $worker
  33. * @return void
  34. */
  35. public static function start($worker)
  36. {
  37. static::$_instance = include config_path() . '/container.php';
  38. }
  39. /**
  40. * @param $name
  41. * @param $arguments
  42. * @return mixed
  43. */
  44. public static function __callStatic($name, $arguments)
  45. {
  46. return static::$_instance->{$name}(... $arguments);
  47. }
  48. /**
  49. * instance
  50. * @return
  51. */
  52. public static function instance()
  53. {
  54. return static::$_instance;
  55. }
  56. }