Laravel源码分析--Laravel生命周期详解

这里我们需要用到php的 xdebug 拓展,所以需要小伙伴们自己去装一下,因为我这里用的是docker,所以就简单介绍下在docker中使用xdebug的注意点。

1、在phpstorm中的 Perferences >> Languages & Framework >> PHP >> debug >> DBGp Proxy 中的Host填写的是宿主机的IP地址。可以在命令行中使用ifconfig / ipconfig查看你的本地IP。

Laravel源码分析--Laravel生命周期详解

2、在 Perferences >> Languages & Framework >> PHP >> Servers 中将你本地项目地址映射到docker容器中的项目地址。

Laravel源码分析--Laravel生命周期详解

3、xdeug.ini的配置。需要特别注意的就是  xdebug.remote_host  填的也是你的宿主机ip。 xdebug.remote_connect_back 配置一定要关掉,否则 xdebug.remote_host 就会不起作用。

当xdebug启动后,效果是这样的

Laravel源码分析--Laravel生命周期详解

 

 

二、Laravel生命周期

1、启动容器

我们知道Laravel所有的请求都会被nginx转发到项目下的 public/index.php 文件中。

<?php /** * Laravel - A PHP Framework For Web Artisans * * @package Laravel * @author Taylor Otwell <taylor@laravel.com> */ define('LARAVEL_START', microtime(true)); /* |-------------------------------------------------------------------------- | Register The Auto Loader |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader for | our application. We just need to utilize it! We'll simply require it | into the script here so that we don't have to worry about manual | loading any of our classes later on. It feels great to relax. | */ require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- | 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'; /* |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can handle the incoming request | through the kernel, and send the associated response back to | the client's browser allowing them to enjoy the creative | and wonderful application we have prepared for them. | */ $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); $response->send(); $kernel->terminate($request, $response);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpxdyw.html