Skip to content

Commit

Permalink
更新示例代码
Browse files Browse the repository at this point in the history
  • Loading branch information
ueaner committed May 10, 2018
1 parent 71c6993 commit af68696
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/Soli/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function setContainer(ContainerInterface $diContainer)
public function getContainer()
{
if ($this->diContainer === null) {
$this->diContainer = Container::instance() ?: new Container;
$this->diContainer = Container::instance() ?: new Container();
}
return $this->diContainer;
}
Expand Down
8 changes: 8 additions & 0 deletions examples/Soli/ExampleApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

class ExampleApp extends Component
{
public function __construct()
{
$this->registerBaseServiceProviders();

$this->registerConfiguredProviders();
// registerCoreContainerAliases();
}

public function registerBaseServiceProviders()
{
(new ConfigServiceProvider)->bind();
Expand Down
4 changes: 4 additions & 0 deletions examples/Soli/Providers/RedisServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class RedisServiceProvider extends ServiceProvider

protected $defer = true;

/**
* @return \Redis
* @throws \Exception
*/
public function register()
{
// 获取 redis 配置信息
Expand Down
4 changes: 0 additions & 4 deletions examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

$app = new \Soli\ExampleApp();

$app->registerBaseServiceProviders();

$app->registerConfiguredProviders();

// 使用访问对象属性的方式,访问容器服务,同 $container->getShared() 方法
$service = $app->testService;
var_dump($service);
Expand Down

0 comments on commit af68696

Please sign in to comment.