PHPackages                             danielemontecchi/laravel-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. danielemontecchi/laravel-patcher

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

danielemontecchi/laravel-patcher
================================

A predictable system for applying one-time operational or data patches in Laravel—trackable, skippable, and rollback-ready.

v1.1.4(1mo ago)08MITPHPPHP ^8.2CI passing

Since May 8Pushed 1mo ago1 watchersCompare

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

READMEChangelog (4)Dependencies (8)Versions (10)Used By (0)

Laravel Patcher
===============

[](#laravel-patcher)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0ffe77937d08feda044303e0ba31ab1422612aba87d3423c8c7e8e9caaf703e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616e69656c656d6f6e7465636368692f6c61726176656c2d706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielemontecchi/laravel-patcher)[![Total Downloads](https://camo.githubusercontent.com/9065cc24e814d4e7057e5a2a86468320ab16c947b5d5a4bf26ff4e8f31a5665d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64616e69656c656d6f6e7465636368692f6c61726176656c2d706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielemontecchi/laravel-patcher)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c0ab29416bf1fd1731e23c3a7293be7b86188b0855b49b5b7bfefc3ef183c78e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64616e69656c656d6f6e7465636368692f6c61726176656c2d706174636865722f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/danielemontecchi/laravel-patcher/actions/workflows/tests.yml)[![Quality Gate Status](https://camo.githubusercontent.com/d1204c58448f40bd4f80eb836c5f9d4fe5c1d74a8cf669a8e636a55d21be7e7f/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d64616e69656c656d6f6e7465636368695f6c61726176656c2d70617463686572266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=danielemontecchi_laravel-patcher)[![Maintainability Rating](https://camo.githubusercontent.com/0ea331291b2b839f7883ae71b1052b556140be4207bf7a8330b8fdea656782c4/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d64616e69656c656d6f6e7465636368695f6c61726176656c2d70617463686572266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/summary/new_code?id=danielemontecchi_laravel-patcher)[![License: MIT](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Documentation](https://camo.githubusercontent.com/09e816ae34b01c0a0c356178a99f4041e3c82696002ef2dd521eb5b0f16c6ace/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d617661696c61626c652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://danielemontecchi.github.io/laravel-patcher)

**Laravel Patcher** is a clean and predictable system for applying one-time patches to your Laravel application. It works similarly to migrations but is designed for operational, data-related, or procedural logic that you need to run once and track.

Inspired by [Taylor Otwell’s patching concept](https://x.com/taylorotwell/status/1387766514674192384?s=46), this package formalizes and extends the idea to support a wide variety of use cases, including conditionally skipped patches, tracking applied states, and batch rollback.

---

Features
--------

[](#features)

- Runs patch classes similar to migrations
- Supports anonymous class patches using `return new class extends Patch`
- Automatically tracks execution via the `patches` database table
- Supports conditional execution via `shouldRun()`
- Distinguishes executed vs skipped patches using `is_applied`
- CLI output styled identically to `php artisan migrate`
- Allows rollback by batch

---

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

[](#installation)

```
composer require danielemontecchi/laravel-patcher
```

Laravel will automatically register the service provider.

To create the required database table, run:

```
php artisan migrate
```

### Patch Table Format

[](#patch-table-format)

The `patches` table includes:

ColumnTypeDescriptionidbigintAuto-increment primary keynamestringPatch filename (without `.php`)batchintBatch number (like migrations)is\_appliedbooleanWhether `shouldRun()` returned `true` and the patch was executedapplied\_attimestampWhen the patch was recorded> Skipped patches are still recorded, but with `is_applied = false`.

---

Creating a Patch
----------------

[](#creating-a-patch)

```
php artisan make:patch FixUsernames
```

This will generate a new file in `database/patches/`:

```
