laravel-ping maintained by koduarve
Description
Simple Ping For Laravel Applications
Author
Last update
2024/01/29 12:00
(dev-master)
License
Downloads
275
Ping for Laravel
This Laravel package is simple and unopinionated. It simply returns the HTTP Status Code for a provided URL.
Installation
Install via Composer:
composer require koduarve/laravel-ping
You'll need to register the ServiceProvider and Facade:
// config/app.php
'providers' => [
// ...
Koduarve\Ping\PingServiceProvider::class,
];
'aliases' => [
// ...
'Ping' => Koduarve\Ping\Facades\Ping::class,
];
Usage
<?php
namespace App\Http\Controllers;
use Ping;
use App\Http\Controllers\Controller;
class HealthServerController extends Controller
{
/**
* Show the current health of a given URL.
*
* @param string $url
* @return string
*/
public function healthCheck($url)
{
$health = Ping::check($url);
if($health == 200) {
return 'Alive!';
} else {
return 'Dead :(';
}
}
}
Credits
- KODUARVE OU - Author
License
The MIT License (MIT). Please see License File for more information.