Symfony 的内核 handle() 函数在哪里调用?

Where is Symfony's Kernel handle() function called?

我想了解 Symfony 的工作原理,所以我正在研究它的内部结构。在 app.php 我有这样的东西:

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';  
require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();    

$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

我感兴趣的是 handle() 函数。 AppKernel 扩展了 Kernel,实现了 KernelInterfacehandle() 函数在 Kernel 中实现,而不是在 AppKernel 中实现。 AppKernel 只注册包和配置文件。函数如下:

   public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
    {
        if (false === $this->booted) {
            $this->boot();
        }

        return $this->getHttpKernel()->handle($request, $type, $catch);
    }

这意味着如果我修改这个函数来做某事,那应该会根据任何请求发生。例如,在函数开头键入 exit; 应该会破坏应用程序。但是,我的应用程序像什么都没发生一样工作。我是看错函数了还是出了什么问题?

我也清过很多次缓存,试过proddev环境都没有成功。

编辑

好像跟bootstrap.php.cache这个文件有关。如果我将其更改为 autoload.php,它就会起作用。问题是删除它后我得到:

Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in E:\svn\medapp\app\AppKernel.php on line 8

这里有什么问题?我怎样才能 运行 一个不依赖自动加载器的应用程序?

Symfony 使用 spl_autoload_register() 函数自动加载每个需要的 class。它使所有 require_once 规则都变得不必要,而只加载我们需要的 classes。我在 bootstrap.php.cache 中找到了这个 spl_autoload_register,所以看起来如果你跳过这个文件加载你也终止了自动加载过程。