Laravel (5.5.33) 加载过程(二)
本次说明代码
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/ $app = require_once __DIR__.'/../bootstrap/app.php';
主要实现的功能
1.实例化 Illuminate\Foundation\Application类
2.初始化基础路径
3.基本容器(app,Container)和对于类的绑定
4.基础服务的注册(事件服务EventServiceProvider 日志服务LogServiceProvider 路由服务RoutingServiceProvider)
5.别名的注册(vendor/laravel/framework/src/Illuminate/Foundation/Application.php文件中的 registerCoreContainerAliases 方法)
流程图

代码
<?php /*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/ /**
* 对于其中的instance register singleton 方法到时候单独拎出来说明
*
* 1.设置基础路径
* 2.使用instance 方法 绑定app 和Illuminate\Foundation\Application类的关系
* 3.使用instance 方法 绑定Container 和Illuminate\Foundation\Application类的关系
* 4.app变量中注册事件服务EventServiceProvider
* 5.app变量中注册日志服务LogServiceProvider
* 6.app变量中注册路由服务RoutingServiceProvider
* 7.别名的注册(vendor/laravel/framework/src/Illuminate/Foundation/Application.php文件中的 registerCoreContainerAliases 方法)
*/
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
); /*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/ /**
* 把App\Http\Kernel::class 类下的参数 映射到lluminate\Contracts\Http\Kernel::class类中
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
); /**
* 把App\Console\Kernel::class 类下的参数 映射到Illuminate\Contracts\Console\Kernel::class类中
*/
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
); /**
* 把App\Exceptions\Handler::class 类下的参数 映射到Illuminate\Contracts\Debug\ExceptionHandler::class类中
*/
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
); /*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/ return $app;
Laravel (5.5.33) 加载过程(二)的更多相关文章
- Laravel (5.5.33) 加载过程(一)
说明: 由于公司项目使用Laravel 框架 也是第一次接触此框架 作为一个新手 记录使用过程的一些事情 以及对于框架源码分析的记录 整理自己的思路 也希望对大家有帮助 如果那里不对的地方 ...
- Laravel (5.5.33) 加载过程---instance方法(二)
在bootstrap/app.php /** * 对于其中的instance register singleton 方法到时候单独拎出来说明 * * 1.设置基础路径 * 2.使用instance 方 ...
- Laravel (5.5.33) 加载过程---make方法(四)
/** * Resolve the given type from the container. * * @param string $abstract * @return mixed */ publ ...
- spring容器启动的加载过程(二)
第六步: public abstract class AbstractApplicationContext extends DefaultResourceLoader implements Confi ...
- JAVA-大白话探索JVM-类加载过程(二)
首先我们知道JVM是什么以及类加载器的作用 不清楚的可以看看JAVA-大白话探索JVM-类加载器(一) 现在我们来摸索下类的加载过程 首先,我们将类加载过程分为三步走 装载 链接 初始化 其中 链接 ...
- 工厂模式模拟Spring的bean加载过程
一.前言 在日常的开发过程,经常使用或碰到的设计模式有代理.工厂.单例.反射模式等等.下面就对工厂模式模拟spring的bean加载过程进行解析,如果对工厂模式不熟悉的,具体可以先去学习一下工厂 ...
- linux内核启动以及文件系统的加载过程
Linux 内核启动及文件系统加载过程 当u-boot 开始执行 bootcmd 命令,就进入 Linux 内核启动阶段.普通 Linux 内核的启动过程也可以分为两个阶段.本文以项目中使用的 lin ...
- JVM——类的加载过程
附一张图方便理解,一个类的执行过程 类的加载过程,简明的来说 类装饰器就是寻找类的字节码文件并构造出类在JVM内部表示的对象组件.在Java中,类装载器把一个类装入JVM中,要经过以下步骤: 装载:查 ...
- (转)JVM类生命周期概述:加载时机与加载过程
原文地址: http://blog.csdn.net/justloveyou_/article/details/72466105 JVM类加载机制主要包括两个问题:类加载的时机与步骤 和 类加载的方式 ...
随机推荐
- POJ 2217 Secretary
Secretary Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: ...
- PatentTips - Hamming distance comparison
BACKGROUND INFORMATION In a typical data processing environment, data may be transmitted in multiple ...
- Ubuntu 16.04安装Grub Customizer替代Startup-manager(解决找不到menu.lst,GRUB配置简单介绍)
关于GRUB的介绍: http://baike.baidu.com/item/GRUB http://blog.csdn.net/bytxl/article/details/9253713 menu. ...
- Ubuntu 16.04设置开机启动应用程序
在终端通过以下命令进行设置,Dash已经搜索不到Startup了: gnome-session-properties 或者直接在Dash中搜索:gnome-session
- c++面试问题的几个方向
1 关于多态,面向对象的几个要点作为面向对象的程序员,这个问题是必须要弄清楚的,网上.教科书上都是标准答案,关键是理解内涵哦. 2 关于虚函数表和RTTI 这个Inside C++ Object Mo ...
- XAPIAN简单介绍(三)
今天主要介绍的是Xapian::Database这个类.先上图 看上去就非常恐怖的吧,我们一点点的说. 首先一切的開始都来自那个include目录中的database.h,他的直接实现是在omdata ...
- [Vue-rx] Pass Template Data Through domStreams in Vue.js and RxJS
domStreams enable you to pass additional data along the stream that can be provided by the template ...
- hdu 3555 Bomb 【数位DP】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题意:上一题是不要62 这个是"不要49" 代码: #include < ...
- HDU 5015 233Matrix (构造矩阵)
233 Matrix Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tota ...
- lua的函数初识
学习到Lua的函数.认为有必要记下来. 參考教程:Programming in Lua 函数能够以表达式或陈述语句出现,例如以下所看到的: print(8*9, 9/8) a = math.sin(3 ...