therealworld/suppress-deprecations-plugin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

therealworld/suppress-deprecations-plugin

Composer 安装命令:

composer require therealworld/suppress-deprecations-plugin

包简介

Suppresses Symfony deprecation notices during Composer operations in legacy OXID 6 projects

README 文档

README

Composer plugin to suppress noisy deprecation notices during composer update / composer install in legacy OXID 6 projects.

Problem

When running Composer commands in OXID 6 projects with current PHP and Composer versions, the console is flooded with non-actionable messages:

Deprecation Notice: Since symfony/event-dispatcher 5.3: Configuring "Symfony\Component\EventDispatcher\..." is deprecated.
Deprecation Notice: Since oxid-esales/oxideshop-ce 6.5.0: The "oxid_esales.module.configuration..." service is deprecated.

These messages cannot be suppressed using PHP's error_reporting because Composer registers its own error handler that explicitly catches and outputs E_USER_DEPRECATED notices.

Solution

The plugin installs a wrapper error handler that intercepts E_USER_DEPRECATED and E_DEPRECATED notices and silently discards them. All other error levels are forwarded to Composer's original ErrorHandler.

Note: Abandoned package warnings ("Package X is abandoned, you should avoid using it.") are printed directly by Composer's Installer via IOInterface::writeError() and cannot be reliably intercepted from a plugin. These warnings are accepted as-is.

Installation

As a dependency of another package (recommended)

In the composer.json of a parent package (e.g. therealworld/clirun-plugin):

{
    "require": {
        "therealworld/suppress-deprecations-plugin": "^1.0"
    }
}

The plugin must be allowed in the project's root composer.json:

{
    "config": {
        "allow-plugins": {
            "therealworld/suppress-deprecations-plugin": true
        }
    }
}

Tip: A wildcard entry covers all therealworld plugins:

{
    "config": {
        "allow-plugins": {
            "therealworld/*": true
        }
    }
}

As a local path repository (for testing)

{
    "repositories": [
        {"type": "path", "url": "extensions/trw/composer"}
    ],
    "require": {
        "therealworld/suppress-deprecations-plugin": "*"
    }
}

Fallback: auto_prepend_file

For the very first composer update (before the plugin is installed), the included suppress-deprecations.php can be used as a PHP prepend file:

php -d auto_prepend_file=extensions/trw/composer/suppress-deprecations.php composer update

This file defines trigger_deprecation() as a no-op before Symfony's version is loaded. From the second run onwards, the plugin takes over.

Files

FilePurpose
src/SuppressDeprecationsPlugin.phpComposer plugin: error handler wrapper
suppress-deprecations.phpFallback: no-op trigger_deprecation() for auto_prepend_file

Technical Background

Why not autoload.files?

Composer's AutoloadGenerator always sorts the root package to the end of the autoload file list ($sortedPackageMap[] = $rootPackageMap). Dependencies are sorted by "importance" (number of dependent packages). symfony/deprecation-contracts has a very high weight and is therefore always loaded before any custom package. Overriding via autoload.files is not possible.

Why not error_reporting?

Composer's ErrorHandler::handle() explicitly checks:

$isDeprecationNotice = $level === E_DEPRECATED || $level === E_USER_DEPRECATED;
if (!$isDeprecationNotice && !(error_reporting() & $level)) {
    return true;
}

Deprecation notices bypass the error_reporting check entirely.

therealworld/suppress-deprecations-plugin 适用场景与选型建议

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

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

围绕 therealworld/suppress-deprecations-plugin 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2026-04-08