laravel5.5入口文件分析
2024-10-20 00:48:37
入口文件 public/index.php
1、加载composer的自动加载器
require __DIR__.'/../vendor/autoload.php';
自动加载,不用再各种require了,更重要的是可以使用composer管理包,管理依赖,可以参考下composer的使用。
2、bootstrap/app.php 得到laravel应用程序实例
$app = require_once __DIR__.'/../bootstrap/app.php';
bootstrap/app.php文件很简单,实例化并注册一些服务
//创建app实例,一切都是由此容器而起,包括服务提供者等等
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
//注册HTTP内核,web端的请求处理,查看下app\http\Kernal父类
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
//注册控制台内核,cli的请求处理
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
//错误处理
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
return $app;
3、HTTP/控制器内核
//上面注册过此服务,这里调用
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
//服务提供者的handle方法
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
最新文章
- C#计算代码行数
- 二叉搜索树(Binary Search Tree)
- ubuntu1404_server搭建lamp
- 1471. Tree(LCA)
- 使用Spring-data-redis操作Redis的Sentinel
- linux下ssh免密登陆
- powerdesigner for sqlserver的一些实用配置
- 在VC6.0中能不能使用Duilib界面库呢?
- 使用 Visual Studio 对exe文件进行数字签名
- iOS 调用私有函数安装app 卸载 app
- 记录一次raid数据恢复及回迁成功的案例
- 记一次小型生产事故 | BeyondComper跨编码方式复制文件内容
- 使用FileUpload实现Servlet的文件上传
- docker(七) 使用dockerfile-maven-plugin插件构建docker镜像
- CentOS 6.5 64位下安装Redis3.0.2的具体流程
- Android 第二波
- 『TensorFlow』读书笔记_进阶卷积神经网络_分类cifar10_上
- 合并多个Excel文件
- java线程池和中断总结
- [No000017E]改善C#程序的建议7:正确停止线程