provider.php 691 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * The following code, none of which has BUG.
  4. *
  5. * @author: BD<liuxingwu@duoguan.com>
  6. * @date: 2019/10/12 19:01
  7. */
  8. use xin\container\Container;
  9. use xin\container\ProviderContainer;
  10. use xin\container\ProviderInterface;
  11. require_once '../vendor/autoload.php';
  12. $app = new ProviderContainer();
  13. $app->addProvider(new class implements ProviderInterface{
  14. /**
  15. * 注册服务
  16. *
  17. * @param \xin\container\Container $container
  18. */
  19. public function register(Container $container){
  20. // TODO: Implement register() method.
  21. $container->singleton('config', function(){
  22. return [
  23. 'title' => 'hello world',
  24. ];
  25. });
  26. }
  27. });
  28. $app->registerProviders();
  29. var_dump($app->config);