Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Composer Patches Laravel Package

cweagans/composer-patches

Apply and manage patch files to Composer dependencies. Lets you keep fixes and tweaks outside vendor/ while still using normal Composer updates, with support for multiple patches per package, remote patch URLs, descriptions, and CI-friendly installs.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install via Composer: composer require --dev cweagans/composer-patches
  • Define patches in your project’s composer.json under the "extra" section:
    {
      "extra": {
        "patches": {
          "drupal/core": {
            "Fix missing method": "patches/core-missing-method.patch"
          }
        }
      }
    }
    
  • Place patch files in your project (e.g., patches/), and run composer install or composer update—patches will apply automatically during dependency resolution.

Implementation Patterns

  • Use patches.json for large patch sets or multi-environment consistency (reference via "patches-file": "patches.json" in extra).
  • Patch third-party packages during CI/CD by ensuring patches/ is committed or generated early in the build.
  • Apply conditional patches using Composer’s platform overrides and replace blocks (e.g., patch symfony/http-foundation only when not using symfony/framework-bundle v6+).
  • Leverage Git submodules or Composer’s git archives for version-controlled, auditable patch files.

Gotchas and Tips

  • Patches apply in composer install, update, and require—but only if the package version changes or the patch metadata changes; use --with-all-dependencies to force reapplication if needed.
  • Path resolution for patch files is relative to the project root, not the package being patched (e.g., "patches/fix-foo.patch" works regardless of target package).
  • PATCHES MISSING: Patches silently fail if the file is missing or the patch applies cleanly—use composer --verbose install and inspect logs for Skipped (already applied) or Could not apply messages.
  • Extend via Composer event hooks: Listen to POST_PATCH_APPLY (newer versions) or manually patch via script triggers if dynamic patching is needed.
  • Avoid patching packages that expose PHPStan/PSR-4 autoloading quirks—patched classmaps may not refresh until composer dump-autoload is run.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport