加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

laravel5.5源码阅读草稿——application

发布时间:2020-12-14 03:46:46 所属栏目:大数据 来源:网络整理
导读:构建方法传入整个项目根目录路径(public文件夹上一级)将其设为基础路径(存在本类basePath属性中)。 __construct setBasePath bindPathsInContainer 在容器中绑定路径 ? bindPathsInContainer instance 在容器中注册已有实例 { $this-removeAbstractAlias
构建方法传入整个项目根目录路径(public文件夹上一级)将其设为基础路径(存在本类basePath属性中)。
__construct > setBasePath > bindPathsInContainer 在容器中绑定路径
?
bindPathsInContainer > instance 在容器中注册已有实例
{
$this->removeAbstractAlias($abstract);这个方法先删除了容器中的对应实例别名
(abstractAliases与aliases有区别,存疑)
$this->rebound 然后如果该键名在bindings属性instances属性aliases属性中任意一个存在,
则运行之前注册该实例时绑定的回调函数进行更新
$this->instances[$abstract] = $instance 最后将路径添加至instances属性
}
?
__construct > registerBaseBindings
{
static::setInstance($this)将application实例注册至Container抽象基类使其全局可用
将IlluminateContainerContainer绑定为application类
绑定了PackageManifest类,vendor路径与bootstrap/cache/packages.php里的服务提供者路径
}
?
__construct > registerBaseServiceProviders 注册了event、日志、路由的服务提供者
传入相应的provider实例,并调用其register方法,将application实例传入provider作为参数进行回调。
RoutingServiceProvider在实例化的时候,又注册了router、urlGenerator、redirector、request、response、dispatcher等类的实例。
将已注册的provider进行标记$this->serviceProviders、$this->loadedProviders[get_class($provider)]
最后追踪到container类的bind方法,也只是把回调函数加入了bindings属性,并设置了是否共享而已
$app->singleton
__construct > registerCoreContainerAliases 将核心类路径存入$this->aliases(别名为键,类名为值)与$this->abstractAliases(类名为键,路径组成的数组为值)中,保存别名

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读