Download the PHP package ukfast/laravel-health-check without Composer

On this page you can find all versions of the php package ukfast/laravel-health-check. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-health-check

UKFast Logo

Tests

Health Check Package

The purpose of this package is to surface a health-check endpoint on /health which, when hit, returns the status of all the services and dependencies your project relies on, along with the overall health of your system. This is useful in both development and production for debugging issues with a faulty application.

This package also adds a /ping endpoint. Just hit /ping and receive pong in response.

Installation

To install the package:

Run composer require ans-group/laravel-health-check to add the package to your dependencies.

This will automatically install the package to your vendor folder.

Laravel

In Laravel applications, the service provider should be automatically registered, but you may register it manually in your config/app.php file:

Lumen

To have the package function in Lumen, you need to register the service provider. add the following to your bootstrap/app.php file:

You can test that the package is working correctly by hitting the /health endpoint.

Configuration

Laravel

Facade

We surface a HealthCheck facade with the package. You can use the passes, fails, or all methods, if you want to access the results of a check or the number of checks running from within your code.

If one of the checks provided cannot be resolved from the service container, we'll throw a CheckNotFoundException with the name of the missing check.

Config

If you'd like to tweak the config file (helpful for configuring the EnvHealthCheck, for example), you can publish it with:

Console command

Check all: php artisan health-check:status

Only specific checks: php artisan health-check:status --only=log,cache

Except specific checks: php artisan health-check:status --except=cache

Middleware

You can register custom middleware to run on requests to the /health endpoint. You can add this to the middleware array in the config/healthcheck.php config file created by the command above, as shown in the example below:

Now your CustomMiddleware middleware will be ran on every request to the /health endpoint.

Lumen

Facade

We surface a HealthCheck facade with the package. You can use the passes, fails, or all methods, if you want to access the results of a check or the number of checks running from within your code.

If one of the checks provided cannot be resolved from the service container, we'll throw a CheckNotFoundException with the name of the missing check.

Config

If you'd like to tweak the config file (helpful for configuring the EnvHealthCheck, for example):

Manually copy the package config file (see example below) to config\healthcheck.php (you may need to create the config directory if it does not already exist).

Update your bootstrap/app.php file to override the default package config:

Middleware

You can register custom middleware to run on requests to the /health endpoint. You can add this to the middleware array in the config/healthcheck.php config file you created using the config above, as shown in the example below:

Now your CustomMiddleware middleware will be ran on every request to the /health endpoint.

Out of the box, the health check package provides:

Checks

Scheduler Health Check

The scheduler health check works by using a time limited cache key on your project every minute. You will need to register the CacheSchedulerRunning command to run every minute in your projects Kernel.php.

You can customise the cache key and length of time in minutes before the scheduler not running will trigger an error.

Creating your own health checks

It's very simple to create your own health checks.

In this example, we'll create a health check for Redis.

You first need to create your health-check class, you can put this inside App\HealthChecks. In this case, the class would be App\HealthChecks\RedisHealthCheck

Every health check needs to extend the base HealthCheck class and implement a status() method. You should also set the $name property for display purposes.

Now we've got our basic class setup, we can add it to the list of checks to run in our config/healthcheck.php file.

Open up config/healthcheck.php and go to the 'checks' array. Add your class to the list of those checks:

If you hit the /health endpoint now, you'll see that there's a my-fancy-redis-check property and it should return OK for the status.

We can now go about actually implementing the check properly.

Go back to the status() method in the RedisHealthCheck class.

Add in the following code:

You'll need to import the following at the top as well

Finally, hit the /health endpoint, depending on if your app can actually hit Redis, you'll see the status of Redis. If it's still returning OK try changing REDIS_HOST to something that doesn't exist to trip the error.

Contributing

We welcome contributions to this package that will be beneficial to the community.

You can reach out to our open-source team via [email protected] who will get back to you as soon as possible.

Please refer to our CONTRIBUTING file for more information.

Security

If you think you have identified a security vulnerability, please contact our team via [email protected] who will get back to you as soon as possible, rather than using the issue tracker.

Licence

This project is licenced under the MIT Licence (MIT). Please see the Licence file for more information.


All versions of laravel-health-check with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
illuminate/console Version ^10.0|^11.0
illuminate/http Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ukfast/laravel-health-check contains the following files

Loading the files please wait ....