PHP code example of dskripchenko / laravel-delayed-process
1. Go to this page and download the library: Download dskripchenko/laravel-delayed-process 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/ */
dskripchenko / laravel-delayed-process example snippets
//Handler.php
class Handler
{
public function handle(int $a, int $b, int $sleep)
{
sleep($sleep);
$c = $a + $b;
return "{$a} + {$b} = {$c}";
}
}
//.....
use Dskripchenko\DelayedProcess\Models\DelayedProcess;
use Handler;
Route::get('/api/create-delayed-process/', function () {
$process = DelayedProcess::make(
Handler::class,
'handle',
1,
2,
100
);
return [
'payload' => $process->toResponse()
];
});
use Illuminate\Support\Facades\Route;
use Dskripchenko\DelayedProcess\Models\DelayedProcess;
Route::get('/api/common/delayed-process/status/{uuid}', function ($uuid) {
/** @var DelayedProcess $process */
$process = DelayedProcess::query()
->where('uuid', $uuid)
->firstOrFail();
return [
'status' => $process->status,
'data' => $process->data,
];
})->name('status-delayed-process');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.