PHPackages                             aaix/laravel-patches - 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. aaix/laravel-patches

ActiveLaravel-package[Utility &amp; Helpers](/categories/utility)

aaix/laravel-patches
====================

A simple, command-based patching system for Laravel where patches are trackable.

1.0.7(9mo ago)0197MITPHPPHP ^8.1CI passing

Since Jun 23Pushed 9mo agoCompare

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

READMEChangelog (5)Dependencies (7)Versions (8)Used By (0)

🛠️ Laravel Patch Commands
=========================

[](#️-laravel-patch-commands)

[![Run Tests](https://github.com/jonaaix/laravel-patches/actions/workflows/run-tests.yml/badge.svg)](https://github.com/aaix/laravel-patches/actions/workflows/run-tests.yml)[![Latest Stable Version](https://camo.githubusercontent.com/e4322dc93b60087fc836accb26293d08f7fbd4db7648a00ae74a9b47ce465d5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616169782f6c61726176656c2d706174636865732e737667)](https://packagist.org/packages/aaix/laravel-patches)[![Total Downloads](https://camo.githubusercontent.com/9f4558d1301e8bba2b57eb45804223f257373b3ecd134d7acdb073cf2d23833e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616169782f6c61726176656c2d706174636865732e737667)](https://packagist.org/packages/aaix/laravel-patches)

A simple, command-based patching system for Laravel. Patches are designed to be hidden, trackable, and disposable one-off commands, ideal for data migrations, one-time fixes, or complex deployments.

---

✨ Features
----------

[](#-features)

- 🧩 **Command-Based:** Every patch is a full-fledged Artisan command.
- 📋 **Trackable:** The system automatically logs which patches have been run in a database table to prevent re-execution.
- 🗑️ **Disposable:** Simply delete the patch file when it's no longer needed.
- 🧠 **User-Controlled Execution:** Unlike migrations, patches are not run automatically. You decide which patch to run and when.

---

📦 Installation
--------------

[](#-installation)

1. **Require the package via Composer:**

    ```
    composer require aaix/laravel-patches
    ```
2. **📂 Configuration (Optional):**

    If you want to customize the configuration, you can optionally publish the config file:

    ```
    php artisan vendor:publish --tag=patches-config
    ```
3. **🛠️ Run the Migration:**

    Simply run the migration command to create the patch\_logs table:

    ```
    php artisan migrate
    ```

If you update this package in the future and additional migrations are added, they will be automatically detected the next time you run php artisan migrate.

---

🚀 Usage
-------

[](#-usage)

### 1️⃣ Create a Patch

[](#1️⃣-create-a-patch)

Use the provided `make:patch` command to create a new patch class. The file will be placed in the `app/Console/Commands/Patches`directory by default.

```
php artisan make:patch FixUserEmails
```

This will generate a file like `app/Console/Commands/Patches/Patch_2025_06_30_FixUserEmails.php`.

---

### 2️⃣ Implement the Patch Logic

[](#2️⃣-implement-the-patch-logic)

Open the newly created file and add your logic to the `handle()` method.

```
// app/Console/Commands/Patches/Patch_2025_06_30_FixUserEmails.php

public function handle(): int
{
    $this->info('Fixing user emails...');

    // Your database queries or other logic here.
    \App\Models\User::whereNull('email_verified_at')->update(['is_active' => false]);

    $this->info('User emails fixed successfully.');

    return self::SUCCESS;
}
```

---

### 3️⃣ Run Patches

[](#3️⃣-run-patches)

**A) Interactively (Recommended)**

Run the main `patch` command to get an interactive list of all pending patches. You can select one or multiple patches to run.

```
php artisan patch
```

This will present a prompt like this:

```
? Which (pending) patches would you like to run?
  [ ] Patch_2025_06_30_FixUserEmails.php
  [ ] Patch_2025_07_01_AnotherFix.php
```

**B) Run a Specific Patch by Signature**If you know the exact signature of a patch, you can run it directly. The signature is generated automatically when you create the patch.

```
php artisan patch:2025_06_30_fix-user-emails
```

The system will run the patch and log its execution. If you try to run the same command again, you will be asked for confirmation.

**C) Non-Interactively (for deployments)**You can run patches non-interactively using the `--all` or `--patch` flags.

- Run a specific patch by name: ```
    php artisan patch --patch=Patch_2025_06_30_FixUserEmails
    ```
- Run all pending patches: ```
    php artisan patch --all
    ```

    ⚠️ Warning: The --all flag should be used with extreme caution. Patches are designed for controlled, deliberate execution. Running all pending patches at once, especially in a production environment, can lead to unintended consequences if the order or combination of patches has not been thoroughly tested. It is highly recommended to run patches individually or in tested groups.

---

### 4️⃣ Check Patch Status

[](#4️⃣-check-patch-status)

To see which patches have been run and which are pending, use the patch:status command.

```
php artisan patch:status
```

This will display two clear, sorted lists:

```
✅ Ran Patches
+------------------------------------------+
| Patch Name                               |
+------------------------------------------+
| Patch_2025_06_20_SomeOldPatch.php        |
+------------------------------------------+

❌ Pending Patches
+------------------------------------------+
| Patch Name                               |
+------------------------------------------+
| Patch_2025_06_30_FixUserEmails.php       |
+------------------------------------------+

```

Patches that have been run and then deleted from the filesystem will not be shown, as they are considered irrelevant.

---

### 5️⃣ Syncing Existing Patches

[](#5️⃣-syncing-existing-patches)

If you are integrating this package into a project that already has numerous patch files, you might want to log them in the database without re-running their code. The `patch:sync` command allows you to do this.

It will find all patch files that are not in the `patch_logs` table and let you interactively select which ones to mark as "run".

```
php artisan patch:sync
```

---

⚙️ Configuration
----------------

[](#️-configuration)

If you need to customize the package, you can publish the configuration file and find it at `config/patches.php`.

- `table`: The name of the database table for logging executed patches.
- `path`: The directory where your patch files are stored.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance57

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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 ~7 days

Total

7

Last Release

284d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d8ec042829e0d4060243b6c1067768dd31773ace52982c6ac4a4fbef207cbfd?d=identicon)[aaix](/maintainers/aaix)

---

Top Contributors

[![jonaaix](https://avatars.githubusercontent.com/u/15804690?v=4)](https://github.com/jonaaix "jonaaix (27 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aaix-laravel-patches/health.svg)

```
[![Health](https://phpackages.com/badges/aaix-laravel-patches/health.svg)](https://phpackages.com/packages/aaix-laravel-patches)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)

PHPackages © 2026

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