hedii / uptime-checker
A php library to monitor website uptime
Installs: 1 052
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 1
Forks: 6
Open Issues: 0
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- php: >=7.0
- phpunit/phpunit: ^5.5
This package is auto-updated.
Last update: 2024-12-18 20:15:19 UTC
README
Uptime Checker
A php library to monitor website uptime
Table of contents
Installation
Install via composer
composer require hedii/uptime-checker
Usage
Instantiation
Create a uptime checker instance:
<?php // require composer autoloader require '/path/to/vendor/autoload.php'; // instantiate $checker = new Hedii\UptimeChecker\UptimeChecker();
Alternatively, you can pass a GuzzleHttp\Client instance as a parameter if you want to set your own http client options (see Guzzle documentation):
// instantiate with the http client as a parameter $checker = new Hedii\UptimeChecker\UptimeChecker(new Client([ 'delay' => 1000, 'allow_redirects' => false ]));
Perform an uptime check
Call the check($url)
method with an url as a parameter to perform the uptime check.
$checker = new Hedii\UptimeChecker\UptimeChecker(); $result = $checker->check('http://example.com');
The result of this method is an array with with the check report information. The value of success
indicates if the website is up or down:
array(5) {
'uri' => "http://example.com"
'success' => true
'status' => 200
'message' => "OK"
'transfer_time' => 0.765217
}
The result array
Testing
composer test
License
hedii/uptime-checker is released under the MIT Licence. See the bundled LICENSE file for details.