PHP code example of anourvalar / laravel-health

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

    

anourvalar / laravel-health example snippets


\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\FilesystemCheck::new()->disks(['s3' => ($checkPublicUrl = true)]),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\OpcacheCheck::new(),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\PusherCheck::new()->connection(null), // default connection
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\QueueFailedCheck::new(),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\XdebugCheck::new(),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\SSLCertCheck::new()
      ->url('google.com')
      ->warnWhenExpiringDay(10)
      ->failWhenExpiringDay(2),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\CpuLoadCheck::new()->failWhenLoadIsHigher(
        2.5, // last minute
        2.0, // last 5 minutes
        1.5  // last 15 minutes
    ),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\GzipCheck::new()
        ->shouldBeGzipped('/')
        ->shouldNotBeGzipped('/image.png'),
]);

Route::any('/health-ping', HealthPingController::class);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\ReverseProxySecurityCheck::new()->url('/health-ping'),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\Http2HttpsCheck::new()
        ->shouldBeRedirected(['/', '/image.png']),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\Www2NoneCheck::new()
        ->shouldBeRedirected(['/', '/image.png']),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\MailerCheck::new()
        ->mailer(null), // default
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\SentryCheck::new(),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\DirectoryPermissionsCheck::new()
        ->writable(storage_path('logs'))
        ->notWritable(app_path('')),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\CorsCheck::new()
        ->allowed('https://good.com')
        ->disallowed('https://evil.com')
        ->url('api/sanctum/csrf-cookie'), // target endpoint
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\CacheHeadersCheck::new()
        ->shouldBeCached('/image.png')
        ->shouldNotBeCached('/'),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\RootCheck::new(),
]);

Route::any('/health-ping', HealthPingController::class);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\FastCGICheck::new()->url('/health-ping'),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\QueueSizeCheck::new()
        ->add(['connection' => null, 'name' => null, 'max_size' => 200]),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\OctaneCheck::new(),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\RedisConfigCheck::new(),
]);

\Spatie\Health\Facades\Health::checks([
    \AnourValar\LaravelHealth\HttpV2::new()->urls('/'),
]);