bangpound / drupal-kernel
Symfony HTTP 核心包装 Drupal 7
dev-master
2013-10-10 02:20 UTC
Requires
- symfony/class-loader: ~2.3
- symfony/http-kernel: ~2.3
- symfony/process: ~2.3
Requires (Dev)
- drupal/drupal: 7.23
This package is auto-updated.
Last update: 2024-09-12 03:28:10 UTC
README
这两个实验性类将 Drupal 7 包装在 Symfony HTTP 核心中。
内核将 Symfony 请求对象序列化到为 Drupal 定制的门面控制器中。门面控制器在一个独立的 PHP 进程中运行。它需要 Composer 自动加载器,以便能够访问 Symfony 类。
在 Drupal 启动之前,注入的请求被反序列化,并将这些值替换为 Drupal 进程中的全局变量。启动 Drupal 进程,处理 Drupal 请求,并将响应作为 PHP CGI 输出回显。
打开进程的内核捕获输出,解析头信息,并返回一个 Symfony 响应对象。
灵感、代码和警告均来自 Igor Wiedler 的 CgiHttpKernel 和 HttpKernelInterface 是谎言。
这不是运行 Drupal 的方法。
用法
只需将 bangpound/drupal-kernel
添加到您的 composer.json
文件中。
{ "require": { "bangpound/drupal-kernel": "dev-master" } }
然后创建一个名为 index.php 的门面控制器,并在其中放入以下代码
<?php $loader = require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .'vendor'. DIRECTORY_SEPARATOR .'autoload.php'; $app = new \Bangpound\Drupal\Kernel($loader, __DIR__ .'/../vendor/drupal/drupal'); $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals(); $response = $app->handle($request); $response->send(); if ($app instanceof \Symfony\Component\HttpKernel\TerminableInterface) { $app->terminate($request, $response); }
如果您需要修改您的 Request 对象,以便它提供 Drupal 所需的所有全局变量,请在将其传递给 handle()
方法之前修改请求对象。