定制 yiisoft/yii-runner-http 二次开发

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

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

yiisoft/yii-runner-http

Composer 安装命令:

composer require yiisoft/yii-runner-http

包简介

HTTP application runner

README 文档

README

Yii

Yii HTTP Runner


Latest Stable Version Total Downloads Build status Code coverage Mutation testing badge Static analysis type-coverage

The package contains a bootstrap for running Yii3 HTTP application.

Requirements

  • PHP 8.1 - 8.5.

Installation

The package could be installed with Composer:

composer require yiisoft/yii-runner-http

General usage

In your HTTP entry script do the following:

use Yiisoft\Yii\Runner\Http\HttpApplicationRunner;

require_once __DIR__ . '/autoload.php';

(new HttpApplicationRunner(
    rootPath: __DIR__, 
    debug: $_ENV['YII_DEBUG'],
    checkEvents: $_ENV['YII_DEBUG'],
    environment: $_ENV['YII_ENV']
))->run();

Additional configuration

By default, the HttpApplicationRunner is configured to work with Yii application templates and follows the config groups convention.

You can override the default configuration using constructor parameters and immutable setters.

Constructor parameters

$rootPath — the absolute path to the project root.

$debug — whether the debug mode is enabled.

$checkEvents — whether check events' configuration.

$environment — the environment name.

$bootstrapGroup — the bootstrap configuration group name.

$eventsGroup — the events' configuration group name.

$diGroup — the container definitions' configuration group name.

$diProvidersGroup — the container providers' configuration group name.

$diDelegatesGroup — the container delegates' configuration group name.

$diTagsGroup — the container tags' configuration group name.

$paramsGroup — the config parameters group name.

$nestedParamsGroups — configuration group names that are included into config parameters group. This is needed for recursive merge parameters.

$nestedEventsGroups — configuration group names that are included into events' configuration group. This is needed for reverse and recursive merge events' configurations.

$configModifiersconfiguration modifiers.

$configDirectory — the relative path from $rootPath to the configuration storage location.

$vendorDirectory — the relative path from $rootPath to the vendor directory.

$configMergePlanFile — the relative path from $configDirectory to merge plan.

$logger — the logger to collect errors while container is building.

$bufferSize — the size of the buffer in bytes to send the content of the message body (default, 8Mb).

$temporaryErrorHandler — a temporary error handler that is needed to handle creating of configuration and container instances.

$emitter — an emitter to send the response.

$useRemoveBodyByStatusMiddleware — whether to remove the body of the response for specific response status codes.

$useContentLengthMiddleware — whether to manage the Content-Length header to the response.

$useHeadRequestMiddleware — whether to remove the body of the response for HEAD requests.

Immutable setters

If the configuration instance settings differ from the default you can specify a customized configuration instance:

/**
 * @var Yiisoft\Config\ConfigInterface $config
 * @var Yiisoft\Yii\Runner\Http\HttpApplicationRunner $runner
 */

$runner = $runner->withConfig($config);

The default container is Yiisoft\Di\Container. But you can specify any implementation of the Psr\Container\ContainerInterface:

/**
 * @var Psr\Container\ContainerInterface $container
 * @var Yiisoft\Yii\Runner\Http\HttpApplicationRunner $runner
 */

$runner = $runner->withContainer($container);

In addition to the error handler that is defined in the container, the runner uses a temporary error handler. A temporary error handler is needed to handle the creation of configuration and container instances, then the error handler configured in your application configuration will be used.

By default, the temporary error handler uses HTML renderer and logging to a file. You can override this as follows:

/**
 * @var Psr\Log\LoggerInterface $logger
 * @var Yiisoft\ErrorHandler\Renderer\PlainTextRenderer $renderer
 * @var Yiisoft\Yii\Runner\Http\HttpApplicationRunner $runner
 */

$runner = $runner->withTemporaryErrorHandler(
    new Yiisoft\ErrorHandler\ErrorHandler($logger, $renderer),
);

Documentation

If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.

License

The Yii HTTP Runner is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

yiisoft/yii-runner-http 适用场景与选型建议

yiisoft/yii-runner-http 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 192.63k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2021 年 11 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「http」 「runner」 「yii」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yiisoft/yii-runner-http 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yiisoft/yii-runner-http 我们能提供哪些服务?
定制开发 / 二次开发

基于 yiisoft/yii-runner-http 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 10
  • Watchers: 15
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2021-11-10