1. Go to this page and download the library: Download wal3fo/laravel-sentinel 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/ */
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Wal3fo\LaravelSentinel\Middleware\CircuitBreakerMiddleware;
final class SendEmailJob implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
public function middleware(): array
{
return [
new CircuitBreakerMiddleware('mail'),
];
}
public function handle(): void
{
// Call external provider here.
}
}
public function middleware(): array
{
return [
new CircuitBreakerMiddleware(['mail', 'crm']),
];
}
namespace App\Jobs;
use Illuminate\Contracts\Queue\ShouldQueue;
use Wal3fo\LaravelSentinel\Attributes\UseCircuitBreaker;
use Wal3fo\LaravelSentinel\Middleware\CircuitBreakerMiddleware;
#[UseCircuitBreaker(['mail'])]
final class SendNotificationJob implements ShouldQueue
{
public function middleware(): array
{
return [new CircuitBreakerMiddleware()];
}
public function handle(): void
{
// Perform work.
}
}
namespace App\Support;
use Throwable;
use Wal3fo\LaravelSentinel\Contracts\FailureClassifier;
final class ApiFailureClassifier implements FailureClassifier
{
public function shouldCount(Throwable $throwable, string $service, array $serviceConfig = []): bool
{
return ! $throwable instanceof \DomainException;
}
}