Skip to content

Repository files navigation

deploymentchecks.http

Packagist VersionPackagist PHP Version SupportLines of codeGitHub code size in bytesCIPackagist DownloadsGitHub

This package provides simple checks for http services. It can check if a service is reachable and if it returns a specific status code, response body, ...

Installation

Easiest way is via composer. Just run composer require codenamephp/deploymentchecks.http in your cli which should install the latest version for you.

You should also explicitly install the codenamephp/deploymentchecks.base package since you will end up using it directly in almost all cases.

Usage

Just create checks, pass them to a collection and run them:

usede\codenamephp\deploymentchecks\base\Check\Collection\SequentialCheckCollection;
usede\codenamephp\deploymentchecks\base\Check\Result\Collection\ResultCollection;
usede\codenamephp\deploymentchecks\http\HttpCheckResult;
usede\codenamephp\deploymentchecks\http\RunTestsOnHttpResponse;
usede\codenamephp\deploymentchecks\http\Test\CssSelectorExists;
usede\codenamephp\deploymentchecks\http\Test\Result\HttpTestResult;
usede\codenamephp\deploymentchecks\http\Test\StatusCode;
useGuzzleHttp\Psr7\Request;
$check = newSequentialCheckCollection(newRunTestsOnHttpResponse(
newRequest('GET', 'https://localhost/test.html'),
'Exists',
newStatusCode(200),
),
newRunTestsOnHttpResponse(
newRequest('GET','https://localhost/404.html'),
'Does not exist',
newStatusCode(404),
),
);
$result = $check->run();
exit($resultinstanceof WithExitCodeInterface ? $result->exitCode() : ($result->successful() ? DefaultExitCodes::SUCCESSFUL->value : DefaultExitCodes::ERROR->value));

About

Package to perform deployment checks using http requests

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages