Skip to content

karlmonson/laravel-ping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 karlmonson/laravel-ping

You'll need to register the ServiceProvider and Facade:

// config/app.php

'providers' => [
    // ...
    Karlmonson\Ping\PingServiceProvider::class,
];

'aliases' => [
    // ...
    'Ping' => Karlmonson\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

License

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

About

Simple Ping for Laravel Applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages