定制 tsmsogn/composer-require-patch-enforcer 二次开发

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

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

tsmsogn/composer-require-patch-enforcer

Composer 安装命令:

composer require tsmsogn/composer-require-patch-enforcer

包简介

Composer plugin that enforces exact x.y.z versions on composer require (no range operators)

README 文档

README

A Composer plugin that blocks composer require unless each package uses an exact three-part version only: major.minor.patch with no range operators (^, ~, >=, *, ||, spaces for compound constraints, etc.). Example: monolog/monolog:3.5.0.

This pushes root requirements toward explicit pins to reduce accidental wide constraints as part of supply-chain hygiene.

Requirements

  • PHP >= 8.1
  • Composer with plugin API ^2.3 (Composer 2.3+)

Installation

From Packagist (recommended)

After the package is registered on Packagist, install a stable release with an exact version (this matches how this plugin expects root requirements to be written once it is active):

composer require tsmsogn/composer-require-patch-enforcer:1.0.0
composer config allow-plugins.tsmsogn/composer-require-patch-enforcer true

The first time you add this package, the plugin is not in vendor yet, so Composer will also accept a range (e.g. ^1.0) for that single command. After the plugin is installed, further composer require calls must use exact x.y.z for every package on the command line (or use COMPOSER_REQUIRE_PATCH_ENFORCER_SKIP=1 / --no-plugins). Upgrading this plugin to 1.0.1 should look like: composer require tsmsogn/composer-require-patch-enforcer:1.0.1.

Development: VCS or path

From Git (no Packagist):

composer config repositories.composer-require-patch-enforcer vcs https://github.com/tsmsogn/composer-require-patch-enforcer.git
composer require tsmsogn/composer-require-patch-enforcer:@dev

From a local path:

composer config repositories.composer-require-patch-enforcer path ../composer-require-patch-enforcer
composer require tsmsogn/composer-require-patch-enforcer:@dev

If the package is not on Packagist, you may need minimum-stability or a stability suffix (e.g. @dev) as above.

Allow the plugin

Composer 2.2+ requires you to opt in to plugins:

composer config allow-plugins.tsmsogn/composer-require-patch-enforcer true

Usage

Every package on the command line must include a version that matches this pattern (whole string, after trim):

  • Optional leading v
  • Three numeric segments: digits.digits.digits
  • Nothing else (no stability suffix like @stable, no pre-release like -alpha)

Regex: ^v?\d+\.\d+\.\d+$

Accepted examples

composer require monolog/monolog:3.5.0
composer require monolog/monolog:v3.5.0
composer require "vendor/package 1.0.0"

Rejected examples

composer require monolog/monolog
composer require monolog/monolog:^3.5.0
composer require monolog/monolog:~3.5.0
composer require "vendor/package >=1.0.0 <2.0.0"
composer require monolog/monolog:^3.5
composer require monolog/monolog:3.5.*
composer require monolog/monolog:3.5.0@stable

These fail because the version is missing, or it is not a single exact x.y.z token.

Interactive composer require with no arguments

If you run composer require without any package arguments, the plugin does not validate (Composer’s interactive wizard may still resolve versions for you). For strict enforcement in CI, use non-interactive mode and always pass explicit package:version arguments.

Disabling enforcement

Temporary (one command):

COMPOSER_REQUIRE_PATCH_ENFORCER_SKIP=1 composer require some/package:^1.0.0

Skip plugins for that invocation:

composer require some/package --no-plugins

Permanent: remove the package from composer.json or set allow-plugins for this package to false and avoid loading it.

Limitations

  • The constraint in composer.json will be that exact string; composer update can still move to a newer version only if you change the constraint — unlike ^, a plain 3.5.0 in require typically means “== that version” for resolution. Transitive dependencies are not controlled by this plugin.
  • Help output is not blocked: composer require -h / --help is ignored by the plugin.

License

MIT

tsmsogn/composer-require-patch-enforcer 适用场景与选型建议

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

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

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

围绕 tsmsogn/composer-require-patch-enforcer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-01