php - 关于lumen源码疑问
本文介绍了php - 关于lumen源码疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
在lumen的Application.php
构造函数中,启动容器的方法
vendor/laravel/lumen-framework/src/Application.php line:103
vendor/illuminate/container/Container.php line:1159
不明白其作用,以及目的。
解决方案
看了下 Lumen 5.3 的源码:
protected function bootstrapContainer()
{
static::setInstance($this);
$this->instance('app', $this);
$this->instance('Laravel\Lumen\Application', $this);
$this->instance('path', $this->path());
$this->registerContainerAliases();
}
结合 $this->instance(...)
来看,就是实现单例模式。
这篇关于php - 关于lumen源码疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文