PHPackages                             sidworks/composer-patcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sidworks/composer-patcher

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

sidworks/composer-patcher
=========================

Composer plugin to automatically apply patches to vendor packages without forking

1.0.8(5mo ago)1275↓23.8%MITPHPPHP ^8.0

Since Dec 11Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/sidworks-dev/composer-patcher)[ Packagist](https://packagist.org/packages/sidworks/composer-patcher)[ Docs](https://github.com/sidworks-dev/composer-patcher)[ RSS](/packages/sidworks-composer-patcher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (1)Versions (10)Used By (0)

Sidworks Composer Patcher
=========================

[](#sidworks-composer-patcher)

[![Latest Version](https://camo.githubusercontent.com/89d501c097a6943c634009e4c06e5d6a1151f0748ddc2db87d0c56c263c374e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736964776f726b732f636f6d706f7365722d706174636865722e737667)](https://packagist.org/packages/sidworks/composer-patcher)[![PHP Version](https://camo.githubusercontent.com/49a13d705ea4d0b1ad24beb3a73018b0244b8c9c985116190d9123447b1e2398/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736964776f726b732f636f6d706f7365722d706174636865722e737667)](https://packagist.org/packages/sidworks/composer-patcher)[![License](https://camo.githubusercontent.com/8e74b4fb443bccb2fa0bd7773717120358d405bfc68ba43e3c555911aabb09aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736964776f726b732f636f6d706f7365722d706174636865722e737667)](LICENSE)

A Composer plugin that automatically applies git-format patches to your project. Useful for patching vendor packages without forking.

Features
--------

[](#features)

- **Automatic patching** - Patches are applied after every `composer install` and `composer update`
- **Development patches** - Use `.patch.dev` files for patches that only apply in dev mode
- **Organized structure** - Supports subdirectories to organize patches by package
- **Idempotent** - Safely re-applies patches on every run (reverses first, then applies)
- **Whitespace tolerant** - Ignores whitespace differences when applying patches
- **Interactive patch creation** - Generate patches from modified vendor files with a single command
- **Clear reporting** - Grouped output showing success/failure status for all patches

Installation
------------

[](#installation)

```
composer require sidworks/composer-patcher
```

Quick Start
-----------

[](#quick-start)

1. Create a `patches` directory in your project root
2. Add `.patch` files (git diff format)
3. Run `composer install`

Directory Structure
-------------------

[](#directory-structure)

```
your-project/
├── composer.json
├── patches/
│   ├── fix-typo.patch              # Applied always
│   ├── debug-helper.patch.dev      # Applied only in dev mode
│   └── acme/                       # Organize by package
│       └── utils/
│           └── fix-calculation.patch
└── vendor/

```

Creating Patches
----------------

[](#creating-patches)

### Using the Built-in Command

[](#using-the-built-in-command)

The easiest way to create a patch from a modified vendor file:

```
composer sidworks:composer-patcher --create
```

This interactive command will:

1. Ask for the file path (e.g., `vendor/acme/utils/src/Calculator.php`)
2. Extract the original file from the package
3. Generate a diff between original and modified versions
4. Ask if you want to save in the package folder (e.g., `patches/acme/utils/`)
5. Save the patch with your chosen filename

Example session:

```
Enter the file path (relative to project root):
> vendor/acme/utils/src/Calculator.php

Save in patches/acme/utils/? [Y/n] y

Enter patch filename [Calculator.php.patch]:
>

✓ Patch created successfully!
Location: patches/acme/utils/Calculator.php.patch

```

### Manually Creating Patches

[](#manually-creating-patches)

Generate a patch using git diff:

```
# For tracked files
git diff vendor/package/file.php > patches/my-fix.patch

# Or from scratch using diff
diff -u original.php modified.php > patches/my-fix.patch
```

Patches must use git-style headers:

```
--- a/vendor/package/src/File.php
+++ b/vendor/package/src/File.php
@@ -10,7 +10,7 @@
     public function example()
     {
-        return 'old';
+        return 'new';
     }
```

Patch Types
-----------

[](#patch-types)

ExtensionApplied When`.patch`Always (install and update)`.patch.dev`Only in dev mode (`composer install` without `--no-dev`)Commands
--------

[](#commands)

### Apply Patches Manually

[](#apply-patches-manually)

```
composer sidworks:composer-patcher
```

Runs the patcher manually (useful for testing). Always runs in dev mode.

### Create a Patch

[](#create-a-patch)

```
composer sidworks:composer-patcher --create
# or
composer sidworks:composer-patcher -c
```

How It Works
------------

[](#how-it-works)

1. On `composer install` or `composer update`, the plugin activates
2. All existing patches are reversed (to handle updates cleanly)
3. Patches are re-applied in alphabetical order
4. Results are displayed grouped by folder
5. If any patch fails, Composer exits with error code 1

Requirements
------------

[](#requirements)

- PHP 8.0+
- Composer 2.x
- Git (for applying patches)

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance72

Regular maintenance activity

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

9

Last Release

157d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ee4de80f0235969a01da2eb7c088d6cf002d75a666728c6be5d81fc7ab186ed?d=identicon)[sidworks](/maintainers/sidworks)

---

Top Contributors

[![jellesiderius](https://avatars.githubusercontent.com/u/8039493?v=4)](https://github.com/jellesiderius "jellesiderius (11 commits)")

---

Tags

composercomposer-patchcomposer-plugingit-patchpatchpatchingphpvendor-patchesplugincomposergitvendorpatchingpatchpatchesvendor-patches

### Embed Badge

![Health badge](/badges/sidworks-composer-patcher/health.svg)

```
[![Health](https://phpackages.com/badges/sidworks-composer-patcher/health.svg)](https://phpackages.com/packages/sidworks-composer-patcher)
```

###  Alternatives

[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M16](/packages/vaimo-composer-patches)[pyrech/composer-changelogs

Display changelogs after each composer update

5904.0M25](/packages/pyrech-composer-changelogs)[sllh/composer-versions-check

Checks if packages are up to date to last major versions after update

2352.4M16](/packages/sllh-composer-versions-check)[netresearch/composer-patches-plugin

Composer patches plugin

80262.1k7](/packages/netresearch-composer-patches-plugin)[ffraenz/private-composer-installer

A composer install helper for private packages

2331.7M5](/packages/ffraenz-private-composer-installer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
