PHP code example of sthira-labs / laravel-deployments

1. Go to this page and download the library: Download sthira-labs/laravel-deployments 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/ */

    

sthira-labs / laravel-deployments example snippets




namespace App\Deployments;

use SthiraLabs\LaravelDeployments\Deployment;
use Illuminate\Support\Facades\DB;

class PatAutomation extends Deployment
{
    public function summary(): array
    {
        return [
            'Run User seeder',
            'Assign permissions to Admin role',
        ];
    }

    protected function handle(): void
    {
        $this->write(
            fn () => DB::table('users')->update(['active' => true]),
            'Activate all users'
        );
    }

    protected function rollback(): void
    {
        DB::table('users')->update(['active' => false]);
    }
}
bash
php artisan vendor:publish --tag=deployments-config
php artisan vendor:publish --tag=deployments-migrations
php artisan vendor:publish --tag=deployments-stubs
bash
php artisan migrate
bash
php artisan make:deployment PatAutomation
bash
# Dry run (no DB writes)
php artisan deploy:run --dry

# Execute deployments
php artisan deploy:run

# Production (
bash
php artisan deploy:status
bash
# Rollback last batch
php artisan deploy:rollback

# Rollback specific batch
php artisan deploy:rollback --batch=1

# Production rollback
php artisan deploy:rollback --force