PHP code example of renoki-co / laravel-healthchecks
1. Go to this page and download the library: Download renoki-co/laravel-healthchecks library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
renoki-co / laravel-healthchecks example snippets
// In your routes
Route::get('/healthcheck', [MyHealthcheckController::class, 'handle']);
public function registerHealthchecks(Request $request)
{
$this->addHealthcheck('mysql', function (Request $request) {
//
});
$this->addHealthcheck('redis', function (Request $request) {
//
});
$this->addHealthcheck('some_check', function (Request $request) {
//
});
$this->addHealthcheck('another_check_here', function (Request $request) {
//
});
}
public function registerHealthchecks(Request $request)
{
$this->setPassingHttpCode(203);
$this->setFailingHttpCode(403);
$this->addHealthcheck('mysql', function (Request $request) {
return true;
});
}
public function registerHealthchecks(Request $request)
{
$this->withOutput();
$this->addHealthcheck('mysql', function (Request $request) {
return true;
});
$this->addHealthcheck('redis', function (Request $request) {
return false;
});
}
php
use Illuminate\Http\Request;
use RenokiCo\LaravelHealthchecks\Http\Controllers\HealthcheckController;
class MyHealthcheckController extends HealthcheckController
{
/**
* Register the healthchecks.
*
* @param \Illuminate\Http\Request $request
* @return void
*/
public function registerHealthchecks(Request $request)
{
$this->addHealthcheck('mysql', function (Request $request) {
// Try testing the MySQL connection here
// and return true/false for pass/fail.
return true;
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.