Install via Composer.
$ composer require shimomo/laravel-ping
Add to config/app.php
.
<?php
return [
// ...
'providers' => [
// ...
Shimomo\Laravel\PingServiceProvider::class,
],
// ...
'aliases' => [
// ...
'Ping' => Shimomo\Laravel\PingFacade::class,
],
];
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
/**
* @author shimomo
*/
class PingController extends Controller
{
/**
* @return string
*/
public function execute()
{
if ($latency = \Ping::execute('https://example.com/')) {
return $latency . 'ms';
}
return 'Not exist.';
}
}
Laravel Ping is open-sourced software licensed under the MIT license.