承接 perfbase/yii1 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

perfbase/yii1

Composer 安装命令:

composer require perfbase/yii1

包简介

Yii 1.1 integration for the Perfbase profiling tool.

README 文档

README

Perfbase

Perfbase for Yii 1.1

Yii 1.1 integration for Perfbase.

Packagist Version License CI PHP Version Yii Version

This package is a thin adapter over perfbase/php-sdk. It keeps the framework layer thin, delegates transport and extension access to the shared SDK, fails open in production, and keeps action naming low-cardinality.

Scope

v1 supports:

  • HTTP request profiling
  • Console command profiling
  • Cron profiling as a classified console sub-context

v1 does not support:

  • Queue workers
  • Custom buffering or retries
  • Yii-specific profiler UI or debug panels

This package is positioned as a legacy-support adapter for real Yii 1.1 applications.

Requirements

  • PHP >=7.4 <8.5
  • Yii 1.1.x
  • perfbase/php-sdk ^1.0
  • The native Perfbase PHP extension available to the target PHP runtime

Installation

composer require perfbase/yii1

Register the component as a preloaded application component in both your web and console configs:

return [
    'preload' => ['perfbase'],
    'components' => [
        'perfbase' => [
            'class' => \Perfbase\Yii1\PerfbaseComponent::class,
            'enabled' => true,
            'api_key' => getenv('PERFBASE_API_KEY') ?: '',
            'sample_rate' => 0.1,
            'app_version' => '1.0.0',
        ],
    ],
];

Composer-based installation is required. Non-Composer Yii 1.1 applications are out of scope.

Configuration

The adapter exposes this config contract:

[
    'enabled' => false,
    'debug' => false,
    'log_errors' => true,
    'api_key' => '',
    'api_url' => 'https://ingress.perfbase.cloud',
    'sample_rate' => 0.1,
    'profile_http_status_codes' => [...range(200, 299), ...range(500, 599)],
    'timeout' => 10,
    'proxy' => null,
    'flags' => \Perfbase\SDK\FeatureFlags::DefaultFlags,
    'app_version' => '',
    'include' => [
        'http' => ['*'],
        'console' => ['*'],
        'cron' => [],
    ],
    'exclude' => [
        'http' => [],
        'console' => [],
        'cron' => [],
    ],
]

Config notes:

  • enabled controls Perfbase profiling, not Yii component loading.
  • include.cron is empty by default. That means console commands profile as source=console unless you explicitly classify them as cron.
  • sample_rate must be numeric and between 0.0 and 1.0.
  • profile_http_status_codes defaults to [...range(200, 299), ...range(500, 599)]. Add codes such as 404 if you want to keep them, or set it to [] to disable HTTP trace submission entirely.
  • app_version is application-defined.
  • environment is derived from YII_ENV when available, otherwise production.

HTTP Profiling

HTTP profiling is attached through Yii 1.1 application events:

  • onBeginRequest starts the HTTP lifecycle
  • onException and onError attach exception context
  • onEndRequest finalizes and submits

Attributes include:

  • source=http
  • action
  • http_method
  • http_url
  • http_status_code
  • user_ip
  • user_agent
  • user_id when Yii user state is available and authenticated
  • hostname
  • environment
  • app_version
  • php_version

Behavior details:

  • action prefers a stable Yii route
  • http_url excludes query strings
  • HTTP traces are only submitted when the response status code is in profile_http_status_codes
  • query parameters are intentionally not included in the primary action/span fields
  • response status defaults to 200 when Yii has not set a more specific status

Console and Cron Profiling

Console profiling also uses application lifecycle hooks:

  • onBeginRequest resolves the console command from $_SERVER['argv']
  • onException and onError mark failures
  • onEndRequest finalizes and submits

Console behavior:

  • normal console commands use source=console
  • commands matching include.cron and not matching exclude.cron use source=cron
  • span names are console.{command} or cron.{command}
  • exit code handling is best-effort and intentionally thin:
    • 0 on normal completion
    • 1 on uncaught exception or error paths

Cron is just a classification of console commands. There is no scheduler-specific integration in v1.

Filters

Each context supports include/exclude filters:

  • http
  • console
  • cron

Supported filter styles:

  • *
  • .*
  • glob patterns such as cache/*
  • regex patterns such as /^GET \/users/

Examples:

'include' => [
    'http' => ['site/*', '/^GET \\/api\\//'],
    'console' => ['cache/*', 'migrate'],
    'cron' => ['schedule/*', 'jobs/run'],
],
'exclude' => [
    'http' => ['debug/*'],
    'console' => ['help'],
    'cron' => ['schedule/test'],
],

Error Handling

The adapter is designed to fail open:

  • if SDK construction fails, profiling becomes a no-op
  • if the extension is unavailable, profiling becomes a no-op
  • if submission fails, the application continues

Error mode behavior:

  • debug=false: swallow errors and optionally log them
  • debug=true: rethrow Perfbase adapter/runtime errors

Runtime Architecture

The package stays intentionally thin:

The adapter does not implement a separate transport or persistence layer.

Development

Install and verify with:

composer install
composer run test
composer run phpstan

Documentation

Full documentation is available at perfbase.com/docs.

License

Apache-2.0. See LICENSE.txt.

perfbase/yii1 适用场景与选型建议

perfbase/yii1 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 perfbase/yii1 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-04-08