PHP code example of simone-bianco / laravel-patches

1. Go to this page and download the library: Download simone-bianco/laravel-patches library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

simone-bianco / laravel-patches example snippets


return [
    'callbacks' => [
        'up' => [
            'before' => null,
            'after' => App\Patches\Hooks\ClearCache::class,
        ],
        'down' => [
            'before' => null,
            'after' => null,
        ],
    ],
];



use SimoneBianco\Patches\Patch;

return new class extends Patch
{
    public bool $transactional = true;

    public function up(): void
    {
        // Apply data changes.
    }

    public function down(): void
    {
        // Reverse data changes.
    }
};



use App\Models\Setting;
use SimoneBianco\Patches\Patch;

return new class extends Patch
{
    public bool $transactional = true;

    public function up(): void
    {
        foreach (     Setting::query()
            ->whereIn('key', array_column(



// data.php
return [
    ['key' => 'site.maintenance', 'value' => false],
];

use SimoneBianco\Patches\Facades\Patches;

$patchesRun = Patches::runPatches();
$rolledBackCount = Patches::rollback();
$rolledBackCount = Patches::rollback(['step' => 5]);
$filePath = Patches::createPatch('settings/site/add_maintenance_mode');
$modulePath = Patches::createPatch('content/seed_homepage', true, true);
bash
composer vendor:publish --provider="SimoneBianco\Patches\PatchesServiceProvider"
php artisan migrate
txt
database/patches/settings/site/2026_07_09_000001_add_maintenance_mode.php
txt
database/patches/countdowns/taiwan_invasion/2026_07_09_010020_seed_projections/
  patch.php
  data.php
  data1.php
  data2.php
  notes.md
  source-map.json
txt
database/patches/settings/site/2026_07_09_000001_add_maintenance_mode.php
txt
database/patches/settings/site/2026_07_09_000001_add_maintenance_mode/patch.php
txt
database/patches/foo/2026_07_09_000001_seed.php
database/patches/foo/2026_07_09_000001_seed/patch.php
bash
php artisan make:patch settings/site/add_maintenance_mode
bash
php artisan make:patch countdowns/taiwan_invasion/seed_projections --module
bash
php artisan make:patch countdowns/taiwan_invasion/seed_projections --module --data
bash
php artisan patch:run
bash
php artisan patch:run --step=1
bash
php artisan patch:single settings/site/2026_07_09_000001_add_maintenance_mode
bash
php artisan patch:rollback
bash
php artisan patch:rollback --step=3
bash
php artisan patch:rollback --step=1 --force
bash
php artisan patch:fresh
txt
database/patches/content/homepage/2026_07_09_000001_seed_page/patch.php
database/patches/content/homepage/2026_07_09_000001_seed_page/data.php

database/patches/content/homepage/2026_07_09_000002_seed_blocks/patch.php
database/patches/content/homepage/2026_07_09_000002_seed_blocks/data.php

database/patches/content/homepage/2026_07_09_000003_seed_sources/patch.php
database/patches/content/homepage/2026_07_09_000003_seed_sources/sources.json