crysix / laravel-ping
Simple Ping For Laravel Applications
1.0.10
2022-03-28 19:00 UTC
Requires
- guzzlehttp/guzzle: >=6.0
- illuminate/support: ^5.1 || ^5.7 || ^5.8 || ^6.0 || ^7.0 || ^8.0
README
This Laravel package is simple and unopinionated. It simply returns the HTTP Status Code for a provided URL.
Installation
Install via Composer:
composer require crysix/laravel-ping
You'll need to register the ServiceProvider and Facade:
// config/app.php 'providers' => [ // ... Crysix\Ping\PingServiceProvider::class, ]; 'aliases' => [ // ... 'Ping' => Crysix\Ping\Facades\Ping::class, ];
Usage
<?php namespace App\Http\Controllers; use Ping; use App\Http\Controllers\Controller; class LinkController 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
- Christian Hinz - Maintainer
- Karl Monson - Original author
- Eric Blount - Inspiration (ericmakesstuff/laravel-server-monitor)
License
The MIT License (MIT). Please see License File for more information.