mlocati/composer-patcher
Composer 安装命令:
composer require mlocati/composer-patcher
包简介
A Composer plugin to patch Composer packages.
README 文档
README
composer-patcher
Simple patches plugin for Composer. Applies a patch from a local or remote file to any package required with Composer.
Usage
Example composer.json:
{
"require": {
"mlocati/composer-patcher": "~1.0",
"concrete5/core": "~8.4"
},
"extra": {
"patches": {
"concrete5/core": {
"This is the patch description": "https://www.example.com/remote.patch",
"This is another patch": "path/relative/to/this/package/local.patch"
}
},
"patches-file": {
"path/relative/to/this/package/patch-list.json"
},
"allow-subpatches": [
"concrete5/core"
],
"patch-errors-as-warnings": true,
"patch-temporary-folder": "/var/tmp"
}
}
If you use the patches-file configuration key, it must be a local or remote JSON file with this syntax:
{
"patches": {
"vendor/project": {
"Patch description #1": "https://www.example.com/remote.patch",
"Patch description #2": "path/relative/to/the/defining/package/local.patch"
}
}
}
Allowing patches to be applied from dependencies
You can use the allow-subpatches to let dependency packages install patches.
It can be:
false[the default] to prevent dependency packages from installing patchestrueto allow all dependency packages installing patches- an array of package handles to whitelist the packages that can install patches
Using patches from HTTP URLs
Composer blocks you from downloading anything from HTTP URLs, you can disable this for your project by adding a secure-http setting in the config section of your composer.json. Note that the config section should be under the root of your composer.json.
{
"config": {
"secure-http": false
}
}
However, it's always advised to setup HTTPS to prevent MITM code injection.
Patch levels
In order to specify the level of a patch, you can use the extended form of the patch path.
For example, if the patch level for a patch should be -p4, you can replace
{
"patches": {
"vendor/project": {
"Patch description": "https://www.example.com/remote.patch",
}
}
}
with
{
"patches": {
"vendor/project": {
"Patch description": {
"path": "https://www.example.com/remote.patch",
"levels": ["-p4"]
}
}
}
}
It can be:
false[the default] to prevent dependency packages from installing patchestrueto allow all dependency packages installing patches- an array of package handles to whitelist the packages that can install patches
Target packages
You can specify the package versions a patch should be applied to. To do so, simply specify the version in the package handle:
{
"patches": {
"vendor/project:1.1.3": {
"Patch description": "https://www.example.com/remote.patch",
}
}
}
You can use the Composer syntax to specify the applicable version(s).
Patches containing modifications to composer.json files
Because patching occurs after Composer calculates dependencies and installs packages, changes to an underlying dependency's composer.json file introduced in a patch will have no effect on installed packages.
If you need to modify a dependency's composer.json or its underlying dependencies, you cannot use this plugin. Instead, you must do one of the following:
- Work to get the underlying issue resolved in the upstream package.
- Fork the package and specify your fork as the package repository in your root
composer.json - Specify compatible package version requirements in your root
composer.json
Error handling
You can use the extra.patch-errors-as-warnings configuration option to instruct composer-patcher what to do in case of errors.
It can be:
true[the default] to simply output an error message in case of errorsfalseto exit composer in case of errors
Credits
A ton of this code is adapted or taken straight from cweagans/composer-patcher.
Do you really want to say thank you?
You can offer me a monthly coffee or a one-time coffee 😉
mlocati/composer-patcher 适用场景与选型建议
mlocati/composer-patcher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 265.66k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2018 年 10 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「composer」 「patch」 「patches」 「patcher」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mlocati/composer-patcher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mlocati/composer-patcher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mlocati/composer-patcher 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Library for merging source data to destination data only if destination data remains valid after that
Monkey patching for exit(), functions, methods, and constants
PHP JSON Patch (RFC6902) implementation
Allows re-building materials from 3rd party libraries with patch
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
统计信息
- 总下载量: 265.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 15
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-12