定制 activecollab/controller 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

activecollab/controller

最新稳定版本:2.1.2

Composer 安装命令:

composer require activecollab/controller

包简介

Invokable controller that accepts containers, works with ETag and more

关键字:

README 文档

README

Build Status

Supported action responses:

  1. \ActiveCollab\Controller\Response\FileDownloadResponse - streams a file download.
  2. \ActiveCollab\Controller\Response\StatusResponse - returns a HTTP status, without response body.
  3. \ActiveCollab\Controller\Response\ViewResponse - Renders a particular view.

When within a controller action, use these methods to get individual request parameters:

  1. getParsedBodyParam()
  2. getCookieParam()
  3. getQueryParam()
  4. getServerParam()

All of these methods accept three parameters:

  1. $request (\Psr\Http\Message\ServerRequestInterface instance)
  2. $param_name (string)
  3. $default (mixed, NULL by default)

Configuration

Controllers can override protected configure() method to do additional setup after controller construction. This method is separated from constructor, so developer does not need to inherit and manage complicated controller constructor.

<?php

namespace App;

use ActiveCollab\Controller\Controller;

class TestController extends Controller
{
    public $is_configured = false;

    protected function configure(): void
    {
        $this->is_configured = true;
    }
}

Exception Handling

When action fails due to an exception, system will return 500 HTTP error, with a message that does not expose any of the system details.

This is done in such a way that new RuntimeException is constructed, with generic error message, and real exception is passed as $previous constructor argument of the new exception. If you have your system configured so exceptions are fully described when 500 errors are rendered (in debug mode for example), you'll be able to access original exception detials like that.

To change default exception message, call setLogExceptionMessage() controller method:

$controller->setLogExceptionMessage('Something weird happened: {exception}');

If $logger is added to the controller (during construction or later on), all exceptions that actions throw will be logged with error level.

To do

  1. Add $payload to status shortcut methods.

统计信息

  • 总下载量: 15.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-11