Download the PHP package code-orange/statuspage without Composer
On this page you can find all versions of the php package code-orange/statuspage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download code-orange/statuspage
More information about code-orange/statuspage
Files in code-orange/statuspage
Package statuspage
Short Description A Lumen package that makes it easy to add a status page to your existing application or to create a dedicated status page application.
License Apache-2.0
Informations about the package statuspage
Statuspage
Statuspage is a Lumen package that allows you to easily add a status page to an existing Lumen application or to create a dedicated Lumen status application.
Live demo of Statuspage. This installation is a dedicated Lumen app monitoring a bigger Laravel app.
Installation
Configuration
First, register the Statuspage ServiceProvider
in your bootstrap/app.php
:
By default, Statuspage will register the status page at /
and a JSON version of it on /json
.
If you want to override this behaviour, you can set the STATUSPAGE_ROUTE
environment variable.
If your route doesn't end in a slash, the JSON version will be hosted at /{$route}.json
.
Statuspage comes with a default HTML page that displays the status of all registered checks.
If you'd like to make changes to this page, you should copy the view (from vendor/code-orange/statuspage/src/views/
) to your own views folder.
You can then set the view you would like Statuspage to render with STATUSPAGE_VIEW
.
For the header on the status page, Statuspage will normally use your APP_NAME
or config('app.name')
followed by the word 'status'.
If you want to use something different, you can set the STATUSPAGE_HEADER
environment variable.
If this variable is set, the page header will be filled with its contents instead of the application name.
The environment variable can contain HTML.
All environment variables are optional.
Usage
Registering checks
Statuspage works by registering StatusChecks
(either alone or in sections) with Statuspage
.
We recommend doing this in the boot
method of your AppServiceProvider
.
Statuspage
exposes two relevant methods.
registerCheck($label, $check)
allows you to register a single check with a label to the status page.registerSection($label, ['Label' => $check, 'Label 2' => $check2])
allows you to register a section with a title and multiple checks to the status page.
For example:
Writing your own checks
While Statuspage comes with a number of basic but useful checks, the real power is in the fact that you can easily define your own custom checks specific to your application.
To do this, simply start by subclassing CodeOrange\Statuspage\Checks\StatusCheck
.
A check usually takes some arguments in its constructor and executes when its performCheck
method is called.
A check always returns an instance of CodeOrange\Statuspage\Status
, optionally with a message.
Background checking
By default, Statuspage executes all checks whenever the page is requested. While this is fine in a small-scale or development setting, it's probably not something you want in production.
To configure Statuspage to instead perform the registered checks in the background, add the following line to your Kernel
's schedule function:
The registered checks will be executed every minute (make sure php artisan schedule:run
is properly configured in your crontab).
The results of your checks are stored in the default cache store (with key statuspage_status
).
Known issues
- The framework doesn't (yet) deal with long-running checks. You are responsible for managing the run-time of your checks and setting timeouts.