bowero/laravel-healthchecks

A Laravel wrapper for healthchecks.io

v1.0.0 2022-03-09 14:06 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Healthchecks.io is a service that monitors your cron jobs and alerts you when they are down. This package is a wrapper for the Healthchecks.io API.

Installation

You can install the package via composer:

composer require bowero/laravel-healthchecks

You then need to publish the configuration file:

php artisan vendor:publish --tag="laravel-healthchecks-config"

This is the contents of the published config file:

return [

    /*
     * The URL endpoint of healthchecks.io
     */
    'url' => 'https://hc-ping.com/',

    /*
     * Your registered jobs
     */
    'jobs' => [
        'my-first-check' => [
            'uuid' => 'c2c0be0a-94fa-4128-aa8a-cd55889cdb29',
        ],
    ],
];

That's it! you can now use the package in your Laravel application. It is automatically registered in your service provider.

Usage

use Bowero\Healthchecks\Facades\Healthchecks;

/*
 * Create a job
 * (the job is registered in healthchecks.php)
 */
$job = Healthchecks::job('my-first-check');

/*
 * Create a job based on the uuid
 */
$job = Healthchecks::uuid('c2c0be0a-94fa-4128-aa8a-cd55889cdb29');

/*
 * Mark the job as started
 */
$job->start();

/*
 * Mark the job as succesful
 */
$job->success();

/*
 * Mark the job as failed
 */
$job->failure();

/*
 * Mark the job as exited with a status code
 */
$job->exitWithStatus(1);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.