tenkoma / cakephp-apache-error-theme

制作Apache网络服务器风格的错误页面。

安装: 4

依赖: 0

建议者: 0

安全: 0

星星: 1

关注者: 1

分支: 0

开放问题: 0

类型:cakephp-plugin

0.1 2017-01-21 14:37 UTC

This package is not auto-updated.

Last update: 2024-09-23 16:36:55 UTC


README

制作Apache网络服务器风格的错误页面。

Not Found

安装

您可以使用 composer 进行安装。

composer require tenkoma/cakephp-apache-error-theme

启用插件

您可以使用shell命令加载插件

bin/cake plugin load CakeApacheErrorTheme

或者,您可以在应用程序的 config/bootstrap.php 文件中手动添加加载语句

// config/bootstrap.php
Plugin::load('CakeApacheErrorTheme');

启用主题

ErrorController::beforeRender() 中设置主题。

// src/Controller/ErrorController.php
    public function beforeRender(Event $event)
    {
        parent::beforeRender($event);

        $this->viewBuilder()->theme('CakeApacheErrorTheme');
    }

并且在 config/app.php 中设置 debug = false

// config/app.php
    'debug' => false,

配置

// config/bootstrap.php
Configure::write('CakeApacheErrorTheme', [
    'signature' => 'cake',
    'email' => 'webmaster@example.com',
]);
  • 签名
    • apache(默认)
    • cake 显示 CakePHP 及其版本作为签名。
  • email(默认=webmaster@localhost)在 5xx 错误时显示的电子邮件地址

示例

404 找不到

Not Found

5xx 内部错误

Internal Error