1. Go to this page and download the library: Download newman/laravel-delay 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/ */
newman / laravel-delay example snippets
use Newman\LaravelDelay\Facades\Delay;
// ...
Delay::for(3);
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Newman\LaravelDelay\Traits\Delayable;
class ImportTask extends Command {
use Delayable;
// ...
}
$this->delay()->for(5);
$this->delay(5);
use Newman\LaravelDelay\Contracts\DelayContract;
// ...
app()->make(DelayContract::class)->for(5);
$this->delay()->for(10)->environments(['production']); // delays only on production
$this->delay()->for(10)->environments(['production', 'staging']); // delays on production and staging only
$this->delay()->for(10)->except(['prodction']); // delays on all environments, except production
$this->delay()->for(10)->except(['prodction', 'staging']); // delays on all environments, except production and staging
$this->delay()->for(10)->exceptWhen(fn () => 1 + 1 == 2); // code will not delay in this case, because callback returns true
$this->delay()->for(10)->exceptWhen(fn () => 1 + 1 == 3); // code will delay in this case, because callback returns false
$this->delay()->for(10)->exceptWhen(fn () => false)->exceptWhen(fn () => false); // code will delay
$this->delay()->for(10)->exceptWhen(fn () => true)->exceptWhen(fn () => false); // code will not delay, because all callbacks doesn't return false