Skip to content

Creating a Patch ​

Scaffold a new patch ​

Use the provided make:patch command. By default, files are placed in app/Console/Commands/Patches.

bash
php artisan make:patch FixUserEmails

This generates a file like:

app/Console/Commands/Patches/Patch_2025_06_30_FixUserEmails.php

The date prefix and signature are generated automatically so patches stay sortable and uniquely identifiable.

Describe the patch ​

The generated file carries a placeholder description. Replace it with what the patch actually repairs:

php
protected $description = 'Strip whitespace from imported user emails';

It is shown next to the file name in the interactive patch picker and in patch:status, where the class name alone rarely says enough.

Implement the patch logic ​

Open the new file and add your logic to the handle() method:

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

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

    \App\Models\User::whereNull('email_verified_at')->update(['is_active' => false]);

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

    return self::SUCCESS;
}

A patch is just an Artisan command, so anything you can do in a command — dependency injection, prompts, progress bars, transactions — is available here.

What's next? ​

Released under the MIT License.