PHPackages                             generationtux/healthz - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. generationtux/healthz

ActiveLibrary

generationtux/healthz
=====================

Health checks for PHP apps.

v4.1.0(4mo ago)2640.2k↓45.8%5[1 PRs](https://github.com/generationtux/php-healthz/pulls)MITPHPPHP ^8.2CI passing

Since Mar 24Pushed 3mo ago20 watchersCompare

[ Source](https://github.com/generationtux/php-healthz)[ Packagist](https://packagist.org/packages/generationtux/healthz)[ RSS](/packages/generationtux-healthz/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (30)Used By (0)

[![Build Test Status](https://github.com/generationtux/php-healthz/actions/workflows/test.yml/badge.svg?event=push)](https://github.com/generationtux/php-healthz/actions/workflows/test.yml/badge.svg?event=push)[![Code Climate](https://camo.githubusercontent.com/3e5ff7a17a37ecce96122714322c467867371d033351b06cbd78096c58aafd8a/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f67656e65726174696f6e7475782f7068702d6865616c74687a2f6261646765732f6770612e737667)](https://codeclimate.com/github/generationtux/php-healthz)[![Test Coverage](https://camo.githubusercontent.com/340d24a158c5a361feda714c196ccd7e1a9130fa182ae4bb66e3119716cd1c52/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f67656e65726174696f6e7475782f7068702d6865616c74687a2f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/generationtux/php-healthz/coverage)

PHP Healthz
===========

[](#php-healthz)

Health checking for PHP apps with built-in support for Laravel.

Requirements
------------

[](#requirements)

- PHP 8.2 - 8.4
- Laravel 10.x - 12.x (for Laravel integration)

[![](https://camo.githubusercontent.com/d78060792a8e17cafff6b62e8b91db2f2f34a945907c81ba810b54502084347e/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f67656e7475782d6465762f646f63732f6865616c74682d636865636b2d73637265656e73686f742e706e67)](https://camo.githubusercontent.com/d78060792a8e17cafff6b62e8b91db2f2f34a945907c81ba810b54502084347e/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f67656e7475782d6465762f646f63732f6865616c74682d636865636b2d73637265656e73686f742e706e67)

Get an easy overview of the health of your app! Implement a health check endpoint for load balancers, or your own sanity :) Comes with an optional UI and set of pre-configured checks you can use, and is extensible to add custom health checks to the stack as well.

- [Setup and usage](#setup)
    - [Laravel](#laravel)
    - [General PHP](#general-php)
- [Available checks and config](#check-configuration)
    - [HTTP](#http-check)
    - [Memcached](#memcached-check)
    - [Debug](#debug-check)
    - [Env)](#env-check)
    - [Database (Laravel)](#laravel-database)
    - [Queue (Laravel)](#laravel-queue)
- [Creating custom checks](#custom-checks)

---

Setup
-----

[](#setup)

```
$ composer require generationtux/healthz
```

### Laravel &lt; 5.4

[](#laravel--54)

(the following should work with Lumen as well, with minor differences)

**Add the service provider that will register the default health checks and routes**

```
// config/app.php
'providers' => [
    Illuminate...,
    Gentux\Healthz\Support\HealthzServiceProvider::class,
]
```

You should be able to visit `/healthz/ui` to see the default Laravel health checks, or run `php artisan healthz` to get a CLI view.

To add basic auth to the UI page, set the `HEALTHZ_USERNAME` and `HEALTHZ_PASSWORD` environment variables. Even if the UI has basic auth, the simplified `/healthz` endpoint will always be available to respond with a simple `ok` or `fail` for load balancers and other automated checks to hit.

**In order to customize the health checks, simply register `Gentux\Healthz\Healthz` in your app service provider (probably `app/Providers/AppServiceProvider.php`) to build a custom Healthz instance.**

```
use Gentux\Healthz\Healthz;
use Illuminate\Support\ServiceProvider;
use Gentux\Healthz\Checks\General\EnvHealthCheck;
use Gentux\Healthz\Checks\Laravel\DatabaseHealthCheck;

class AppServiceProvider extends ServiceProvider
{
        public function register()
        {
                $this->app->bind(Healthz::class, function () {
                        $env = new EnvHealthCheck();
                        $db = new DatabaseHealthCheck();
                        $db->setConnection("non-default");

                        return new Healthz([$env, $db]);
                });
        }
}
```

[See more about configuring available checks](#check-configuration)

---

### General PHP

[](#general-php)

**Build an instance of the health check**

```
