CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 徽标和商标
  • 商业解决方案
  • 商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题 (Github)
    • 烘焙坊
    • 特色资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 时事通讯
    • 领英
    • 优兔
    • 脸书
    • 推特
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • 缓存
    • 集合
    • 命令
    • 控制台
    • 控制器
    • 核心
    • 数据库
    • 数据源
    • 错误
    • 事件
    • 表单
    • Http
      • 客户端
      • Cookie
      • 异常
      • 中间件
      • 会话
      • 测试套件
    • 国际化
    • 日志
    • 邮件
    • 网络
    • ORM
    • 路由
    • 测试套件
    • 实用工具
    • 验证
    • 视图

类服务器

运行应用程序,调用所有 PSR7 中间件和注册的应用程序。

命名空间: Cake\Http

属性摘要

  • $_eventClass 受保护
    字符串

    新事件对象的默认类名。

  • $_eventManager 受保护
    Cake\Event\EventManagerInterface|null

    Cake\Event\EventManager 的实例,此对象正在使用它来分发内部事件。

  • $app 受保护
    Cake\Core\HttpApplicationInterface
  • $runner 受保护
    Cake\Http\Runner

方法摘要

  • __construct() 公开

    构造函数

  • bootstrap() 受保护

    应用程序引导包装器。

  • dispatchEvent() 公开

    用于创建和分发事件的包装器。

  • emit() 公开

    使用 PHP SAPI 发射响应。

  • getApp() 公开

    获取当前应用程序。

  • getEventManager() 公开

    获取应用程序的事件管理器或全局事件管理器。

  • run() 公开

    在应用程序及其中间件中运行请求/响应。

  • setEventManager() 公开

    设置应用程序的事件管理器。

方法详情

__construct() ¶ 公开

__construct(Cake\Core\HttpApplicationInterface $app, Cake\Http\Runner|null $runner = null)

构造函数

参数
Cake\Core\HttpApplicationInterface $app

要使用的应用程序。

Cake\Http\Runner|null $runner 可选

应用程序运行器。

bootstrap() ¶ 受保护

bootstrap(): void

应用程序引导包装器。

调用应用程序的 bootstrap() 钩子。在应用程序之后,插件会被引导。

返回值
void

dispatchEvent() ¶ 公开

dispatchEvent(string $name, array $data = [], TSubject|null $subject = null): Cake\Event\EventInterface<TSubject>

用于创建和分发事件的包装器。

返回一个已分发的事件。

参数
字符串 $name

事件名称。

数组 $data 可选

您希望通过此事件传递的任何值,都可以由侦听器读取。

TSubject|null $subject 可选

此事件适用的对象(默认情况下为 $this)。

返回值
Cake\Event\EventInterface<TSubject>

emit() ¶ 公开

emit(Psr\Http\Message\ResponseInterface $response, Cake\Http\ResponseEmitter|null $emitter = null): void

使用 PHP SAPI 发射响应。

在响应发出后,将触发 Server.terminate 事件。

Server.terminate 事件可用于在响应发送到客户端后执行可能很重的任务。只有 PHP FPM 服务器 API 能够在服务器的 PHP 进程执行某些任务时向客户端发送响应。对于其他环境,该事件将在响应刷新到客户端之前触发,将不会有任何好处。

参数
Psr\Http\Message\ResponseInterface $response

要发出的响应。

Cake\Http\ResponseEmitter|null $emitter 可选

要使用的发射器。当为 null 时,将使用 SAPI 流发射器。

返回值
void

getApp() ¶ 公开

getApp(): Cake\Core\HttpApplicationInterface

获取当前应用程序。

返回值
Cake\Core\HttpApplicationInterface

getEventManager() ¶ 公开

getEventManager(): Cake\Event\EventManagerInterface

获取应用程序的事件管理器或全局事件管理器。

您可以使用此实例向对象事件注册任何新的侦听器或回调,或创建您自己的事件并随意触发它们。

返回值
Cake\Event\EventManagerInterface

run() ¶ 公开

run(Psr\Http\Message\ServerRequestInterface|null $request = null, Cake\Http\MiddlewareQueue|null $middlewareQueue = null): Psr\Http\Message\ResponseInterface

在应用程序及其中间件中运行请求/响应。

这将调用以下方法

  • App->bootstrap() - 在此处执行应用程序的任何引导逻辑。
  • App->middleware() - 在此处附加任何应用程序中间件。
  • 触发 'Server.buildMiddleware' 事件。您可以使用它从事件侦听器中修改。
  • 运行中间件队列,包括应用程序。
参数
Psr\Http\Message\ServerRequestInterface|null $request 可选

要使用的请求或 null。

Cake\Http\MiddlewareQueue|null $middlewareQueue 可选

MiddlewareQueue 或 null。

返回值
Psr\Http\Message\ResponseInterface
抛出
RuntimeException
当应用程序没有做出响应时。

setEventManager() ¶ 公开

setEventManager(Cake\Event\EventManagerInterface $eventManager): $this

设置应用程序的事件管理器。

如果应用程序不支持事件,则会引发异常。

参数
Cake\Event\EventManagerInterface $eventManager

要设置的事件管理器。

返回值
$this
抛出
InvalidArgumentException

属性详情

$_eventClass ¶ 受保护

新事件对象的默认类名。

类型
字符串

$_eventManager ¶ 受保护

Cake\Event\EventManager 的实例,此对象正在使用它来分发内部事件。

类型
Cake\Event\EventManagerInterface|null

$app ¶ 受保护

类型
Cake\Core\HttpApplicationInterface

$runner ¶ 受保护

类型
Cake\Http\Runner
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 徽标和商标
  • 社区
  • 参与
  • 问题 (Github)
  • 烘焙坊
  • 特色资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • 领英
  • 优兔
  • 脸书
  • 推特
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成