chocofamilyme/laravel-healthcheck
Serves functionality of healthchecks of your application
135,504
11
| Install | |
|---|---|
composer require chocofamilyme/laravel-healthcheck |
|
| Latest Version: | 4.0.0 |
| PHP: | ^8.0.2 |
| Laravel: | 8 · 9 · 10 |
| Older releases: | 5 · 6 · 7 |
| License: | BSD-3-Clause |
| Last Updated: | Mar 7, 2023 |
| Links: | GitHub · Packagist |
Maintainer: chocofamilyme
Laravel Health Check Library
Health Check library adds new endpoints(routes) to your project which are used to check some services of your application. For example you want to check "Database Connection" of your microservice.
Installation
composer require chocofamilyme/laravel-healthcheck ^2.0
Publishing the configuration (optional)
php artisan vendor:publish --provider="Chocofamilyme\LaravelHealthCheck\Providers\HealthCheckServiceProvider"
Checks
- Database connection check
- Cache write&read check
- Sessions write&read check
- Storage check
Routes
- /health
{
"DB": "OK",
"CACHE": "OK",
"SESSIONS": "CRITICAL",
"STORAGE": "OK"
}
- /health/extended
{
"DB": {
"STATUS": "OK",
"STATUS_BOOL": true,
"MESSAGE": null
},
"CACHE": {
"STATUS": "OK",
"STATUS_BOOL": true,
"MESSAGE": null
},
"SESSIONS": {
"STATUS": "CRITICAL",
"STATUS_BOOL": false,
"MESSAGE": "Connection to tarantool.example.com failed"
},
"STORAGE": {
"STATUS": "OK",
"STATUS_BOOL": true,
"MESSAGE": null
}
}
How to write your custom checks
Create a class which implements Chocofamilyme\LaravelHealthCheck\Services\Checks\ComponentCheckInterface and add it to healthcheck.php config file like
return [
'componentChecks' => [
'YOURCUSTOMCHECK' => YourCustomCheck::class
]
]
Responses
There is a configuration param which describes which response class to use to output the response. For example
- /health - Chocofamilyme\LaravelHealthCheck\Responses\Response::class output would look like this
{
"DB": "OK",
"CACHE": "OK",
"SESSIONS": "CRITICAL",
"STORAGE": "OK"
}
- /health - Chocofamilyme\LaravelHealthCheck\Responses\Response::class output would look like this
{
"data": {
"DB": "OK",
"CACHE": "OK",
"SESSIONS": "CRITICAL",
"STORAGE": "OK"
}
}
Feel free to add your responses, if you want for example to output it in a view instead json.
Related Packages
postalservice14/php-actuator
PHP port of Spring Actuator which provides an easy health checking capability of...
39,859
10
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 4.0.0 | ^8.0.2 | ^8.0| | BSD-3-Clause | |
| 3.0.0 | ^8.0.2 | ^8.0| | BSD-3-Clause | |
| 2.0.1 | >= 7.4 | ^8.0 | BSD-3-Clause | |
| 2.0.0 | >= 7.4 | ^8.0 | BSD-3-Clause | |
| 1.0.2 | >= 7.1.0 | ^6.0| | BSD-3-Clause | |
| 1.0.1 | >= 7.1.0 | ^6.0| | BSD-3-Clause | |
| 1.0.0 | >= 7.1.0 | ^6.0| | BSD-3-Clause | |
| 0.0.6 | >= 7.0.0 | ^5.7| | BSD-3-Clause | |
| 0.0.5 | >= 7.0.0 | ^5.7| | BSD-3-Clause | |
| 0.0.4 | >= 7.0.0 | ^5.7| | BSD-3-Clause | |
| 0.0.3 | >= 7.0.0 | ^5.7| | BSD-3-Clause | |
| 0.0.2 | >= 7.0.0 | ^5.7| | BSD-3-Clause | |
| 0.0.1 | >= 7.0.0 | ^5.7| | BSD-3-Clause |