2017 © Pedro Peláez
 

library stack-heartbeat

Stack middleware which provides a heartbeat url for your application

image

bramr/stack-heartbeat

Stack middleware which provides a heartbeat url for your application

  • Saturday, June 4, 2016
  • by bramr
  • Repository
  • 2 Watchers
  • 1 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Stack\Heartbeat

A simple Stack middleware which adds a route to your application to respond to heartbeat requests., (*1)

Build Status Code Coverage, (*2)

Installation

The easiest way to install stack-heartbeat is through Composer., (*3)

composer require bramr/stack-heartbeat

Usage

By default the middleware responds to the route: /heartbeat.check with a plain text message "OK", (*4)

public function __construct(HttpKernelInterface $app, $route = '/heartbeat.check', callable $handler = null)

The optional constructor arguments allows you to change the route or add a custom handler when the route is called. This allows you to alter the response but also to add checks to your application which check dependencies like a database, files, etc., (*5)

An example:, (*6)

$app = new  CallableHttpKernel(function (Request $request) {
    return new Response('#yolo');
});

$app = (new Stack\Builder)
    ->push(BramR\Stack\Heartbeat::class)
    ->push(BramR\Stack\Heartbeat::class, '/custom', function () use ($diContainer) {
        return new Response(
            'Implement custom heartbeat check, to check some stuff in db:' . $diContainer['db.name']
        );
    })
    ->resolve($app);

Stack\run($app);

See example.php for a complete (and more complicated) example., (*7)

License

MIT, for details see LICENSE file., (*8)


Inspired by Rack::Heartbeat., (*9)

The Versions

04/06 2016

dev-master

9999999-dev

Stack middleware which provides a heartbeat url for your application

  Sources   Download

MIT

The Requires

 

The Development Requires

04/06 2016

v1.0.0

1.0.0.0

Stack middleware which provides a heartbeat url for your application

  Sources   Download

MIT

The Requires

 

The Development Requires