antecedent/patchwork
Patchwork is a PHP library for monkey patching: redefine functions, methods, and classes at runtime to ease testing and legacy refactors. Works with Composer and popular test tools, enabling stubs/mocks without changing existing code.
Adopt when:
date(), file_get_contents()) without modifying source files.Look elsewhere if:
For Executives: "Patchwork lets us test and extend legacy PHP systems without rewriting them—saving 6–12 months of dev effort. For example, we can stub out a third-party payment gateway’s static methods to test our checkout flow, or dynamically inject logging into production to debug a critical bug. This reduces risk in modernizing our stack while keeping legacy systems running. The MIT license and active maintenance make it a low-risk choice."
For Engineers:
*"This is like PHP’s dd() for functions—you can override any global/static method at runtime to:
Mail::send() → return a fake response).User::find() with slow queries).Auth::attempt() to simulate admin sessions).
It’s lightweight, works with Laravel, and avoids the pitfalls of manual hacks. Use it for tests, debugging, or temporary fixes—never for permanent changes."*How can I help you explore Laravel packages today?