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


    构建方法传入整个项目根目录路径(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(类名为键,路径组成的数组为值)中,保存别名
  • 相关阅读:
    批处理基础知识-IF
    在Windows 10 x64 编译ReactOS-0.4.5源码并在VMare中运行
    复制20天以前指定的文件夹、子文件夹和子文件至指定目录
    bat(批处理)命令(tomcat 7.0.75 startup.bat 命令集)
    mycat
    mysql
    5种网络IO模型
    Linux常用命令
    mybatis多参数传递,延迟加载,缓存,注解开发
    事务,mybatis
  • 原文地址:https://www.cnblogs.com/wyycc/p/9601947.html
Copyright © 2020-2023  润新知