Skip to content
Add a simple status page to applications.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
resources/views
src
tests
.gitignore
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
composer.json
composer.lock
phpunit.xml.dist

README.md

StatusPage

Build Status Scrutinizer Code Quality

Add a simple status page to applications with custom checks.

The status page runs all registered checks and renders a page showing its results.

Installation

composer require bretrzaun/statuspage

Standalone usage

$checker = new \BretRZaun\StatusPage\StatusChecker();
// add your checks here
$checker->addCheck(...);

// in different groups if you like
$group = new StatusCheckerGroup('Group 01');
$group->addCheck(...);
$group->addCheck(...);
$checker->addGroup($group);

// run the checks
$checker->check();

// use the built-in Twig template
$loader = new Twig_Loader_Filesystem('resources/views/');
$twig = new Twig_Environment($loader, ['autoescape' => false]);

$content = $twig->render(
    'status.twig',
        [
            'results' => $checker->getResults(),
            'title' => 'My status page'
        ]
    );
$code = $checker->hasErrors() ? 503 : 200;    
// create a response with $content and $code     

Usage with Silex

Registering the service provider you add the checks via a callback method:

$app->register(new \BretRZaun\StatusPage\StatusPageServiceProvider(), array(
    'statuspage.title' => 'MySilexApp - Status Page',
    'statuspage.checker' => $app->protect(function($app, $statusChecker) {
        $check = new \BretRZaun\StatusPage\Check\DoctrineConnectionCheck('Database', $app['db']);
        $statusChecker->addCheck($check);
        
        // ... add more checks or groups here
    })
));

Out-of-the-box checks

  • CallbackCheck: generic check using a PHP callback function
  • DoctrineConnectionCheck: checks for a valid Doctrine DBAL connection
  • ElasticsearchCheck: checks an Elasticsearch Client for successful pings
  • LogFileContentCheck: check a (log) file for certain content
  • UrlCheck: checks a URL
  • PhpExtensionCheck: check a given PHP extension is loaded
  • PhpMemoryLimitCheck: check PHP memory limit
  • PhpVersionCheck: check PHP version

Custom checks

Custom checks can be easily added by inheriting BretRZaun\StatusPage\Check\AbstractCheck.

Tests

To run the tests, just enter:

composer install
vendor/bin/phpunit
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.