koduarve / laravel-ping
为 Laravel 应用程序的简单 Ping 工具
1.0.2
2024-01-29 11:00 UTC
Requires
- guzzlehttp/guzzle: ^6.0 || ^7.0 || ^8.0
- illuminate/support: ^5.1 || ^5.7 || ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
This package is auto-updated.
Last update: 2024-09-29 12:21:52 UTC
README
这个 Laravel 包简单且无偏见。它只简单地返回提供的 URL 的 HTTP 状态码。
安装
通过 Composer 安装
composer require koduarve/laravel-ping
您需要注册 ServiceProvider 和 Facade
// config/app.php 'providers' => [ // ... Koduarve\Ping\PingServiceProvider::class, ]; 'aliases' => [ // ... 'Ping' => Koduarve\Ping\Facades\Ping::class, ];
用法
<?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 :('; } } }
致谢
- KODUARVE OU - 作者
许可证
MIT 许可证 (MIT)。更多信息请参阅 许可证文件。