Dead simple PHP server health API endpoint. No dependencies, customizable, lightweight, fast, powerful. Pick all five.
Let’s get started with the basics!
Drop the index.php
file onto your web server.
You need PHP 7.4 or higher installed.
A single endpoint that returns a JSON response with the server health.
You can also configure basic token authentication and configure what data is shown.
Remember that health checks may expose sensitive information about your server configuration.
Make sure to secure the endpoint properly, or take care to limit the information shown to the public.
We provide a very basic token authentication mechanism. Remember, by default anyone can access the endpoint.
To enable authentication, either set an APP_AUTH_TOKEN
environment variable or edit the index.php
file and set the Config::APP_AUTH_TOKEN
constant.
In both cases, this constant should be the sha256
hash of the token you want to use.
The token can then be passed either as a Bearer
token in the Authorization
header or as a token
query parameter.
The MIT License
Here is a demo of the endpoint: health.php