PHPackages                             browncat/healthcheck-bundle - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. browncat/healthcheck-bundle

ActiveSymfony-bundle[Logging &amp; Monitoring](/categories/logging)

browncat/healthcheck-bundle
===========================

Tool for health checks

v1.0.1(3y ago)12.1k↓33.3%MITPHPPHP ^7.2 || ^8.0

Since Jun 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/browncat-nl/HealthCheckBundle)[ Packagist](https://packagist.org/packages/browncat/healthcheck-bundle)[ RSS](/packages/browncat-healthcheck-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (13)Versions (3)Used By (0)

Health Check Bundle
===================

[](#health-check-bundle)

This bundle can be used to easily write health checks and expose endpoints which can be used by e.g. Kubernetes to determine the health of the application.

This bundle consists of two core components that interweave with eachother, **checkers** and **checks**.

- A (health) check is an component which contains logic to check if the system is behaving correctly.
- A (health) checker runs these checks when needed. For example when the endpoint `/healthz` is requested.

Usage
-----

[](#usage)

This package can be installed using composer:

`composer require browncat/healthcheck-bundle`

### Enable endpoints

[](#enable-endpoints)

This bundle comes with a set of endpoints which can be enabled to expose the following set of endpoints:

- `/health/liveness` Returns 503 if one or multiple checks fail. Coupled to `LivenessChecker`
- `/health/readiness` Returns 503 if one or multiple checks fail. Coupled to `ReadinessChecker`
- `/health/startup` Returns 503 if one or multiple checks fail. Coupled to `StartupChecker`
- `/healthz` JSON result of all checks, returns 503 if one or multiple checks fail.

To enable them all add the following to your `routes.yaml`:

```
health:
  resource: "@HealthCheckBundle/Resources/config/routes.xml"
```

Bundle provided health checks
-----------------------------

[](#bundle-provided-health-checks)

This bundle comes with some pre defined health checks. These checks are not enabled by default as to not get into the way of your workflow. They can be enabled and configured through Symfony's config component.

### Enable bundle provided health checks

[](#enable-bundle-provided-health-checks)

To enable for example the check `doctrine.connection` create or modify the file `config/packages/healthcheck.yaml` and add the following:

```
# config/packages/healthcheck.yaml

health_check:
    checks:
        doctrine.connection:
```

A list of package provided health checks can be found [here](#list-of-bundle-provided-health-checks).

The config above will enable the doctrine connection check for all available checkers. To use a subset of checkers add the following to the config:

```
# config/packages/healthcheck.yaml

health_check:
    checks:
        doctrine.connection:
            checkers:
                - Browncat\HealthCheckBundle\Checker\LivenessChecker
                - Browncat\HealthCheckBundle\Checker\ReadinessChecker
```

A list of availble checkers can be found [here](#list-of-available-checkers)

### List of bundle provided health checks

[](#list-of-bundle-provided-health-checks)

iddescriptionsincedoctrine.connectionChecks if all connections configured in doctrine work.v0.1.0Creating your own health checks
-------------------------------

[](#creating-your-own-health-checks)

Health checks are defined in classes extending `Browncat\HealthCheckBundle\Check\HealthCheck`. For example, you may want to check the connection between the application and a remote system:

```
// src/Check/ExampleCheck.php
