PHP code example of ebs / parents-one-time-operations

1. Go to this page and download the library: Download ebs/parents-one-time-operations 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/ */

    

ebs / parents-one-time-operations example snippets


// config/one-time-operation.php

return [
    'directory' => 'operations',
    'table' => 'operations',
];


// operations/XXXX_XX_XX_XXXXXX_awesome_operation.php

use TimoKoerber\LaravelOneTimeOperations\OneTimeOperation;

return new class extends OneTimeOperation
{
    /**
     * Determine if the operation is being processed asyncronously.
     */
    protected bool $async = true;

    /**
     * Process the operation.
     */
    public function process(): void
    {
        //
    }
};


// operations/XXXX_XX_XX_XXXXXX_awesome_operation.php

public function process(): void
{
    User::where('active', 1)->update(['status' => 'awesome']) // make active users awesome
}
shell
php artisan migrate
shell
php artisan operations:make <operation_name> // create operation file
shell
php artisan operations:process                   // process operation files
php artisan operations:process --sync            // force syncronously execution
php artisan operations:process --async           // force asyncronously execution
php artisan operations:process --test            // dont flag operations as processed
php artisan operations:process <operation_name>  // re-run one specific operation
shell
...
 - php artisan migrate
 - php artisan operations:process
...
shell
php artisan vendor:publish --provider="TimoKoerber\LaravelOneTimeOperations\Providers\OneTimeOperationsServiceProvider"
shell
php artisan operations:make AwesomeOperation
shell
php artisan operations:process
shell
php artisan operations:process --async  // force dispatch()
php artisan operations:process --sync   // force dispatchSync()  
shell
php artisan operations:process XXXX_XX_XX_XXXXXX_awesome_operation
shell
php artisan operations:process --test