{"id":14975853,"url":"https://github.com/fullpipe/check-them","last_synced_at":"2025-10-27T14:31:18.741Z","repository":{"id":62507903,"uuid":"311044289","full_name":"fullpipe/check-them","owner":"fullpipe","description":"Health checks for external services","archived":false,"fork":false,"pushed_at":"2021-03-08T08:26:16.000Z","size":33,"stargazers_count":33,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T06:31:45.069Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fullpipe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-08T11:12:05.000Z","updated_at":"2024-11-02T20:55:43.000Z","dependencies_parsed_at":"2022-11-02T13:16:11.976Z","dependency_job_id":null,"html_url":"https://github.com/fullpipe/check-them","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fullpipe%2Fcheck-them","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fullpipe%2Fcheck-them/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fullpipe%2Fcheck-them/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fullpipe%2Fcheck-them/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fullpipe","download_url":"https://codeload.github.com/fullpipe/check-them/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238508861,"owners_count":19484215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:52:46.148Z","updated_at":"2025-10-27T14:31:18.321Z","avatar_url":"https://github.com/fullpipe.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Health checks for external services\n\n## Install\n\n```bash\ncomposer require fullpipe/check-them\n```\n\n## Usage\n\n```php\nuse Fullpipe\\CheckThem\\Checks\\PDOCheck;\n\n$mysqlCheck = new PDOCheck('mysql:dbname=test_db;host=127.0.0.1:3306', 'username', 'password');\n$status = $mysqlCheck-\u003egetStatus();\n\nif(!$status-\u003eisUp()) {\n    $this-\u003elogger-\u003ewarn('Mysql server is down', $status-\u003egetError());\n    exit;\n}\n```\n\nor use AllInOneCheck\n\n```php\n\nuse Fullpipe\\CheckThem\\Checks\\AllInOneCheck;\nuse Fullpipe\\CheckThem\\Checks\\PDOCheck;\nuse Fullpipe\\CheckThem\\Checks\\HttpCheck;\nuse Fullpipe\\CheckThem\\Checks\\RedisChecker;\n\n...\n\n$allInOne = new AllInOneCheck();\n\n$allInOne-\u003eadd(new PDOCheck('mysql:dbname=test_db;host=127.0.0.1:3306', 'username', 'password'));\n$allInOne-\u003eadd(new HttpCheck('user_service:8080'));\n$allInOne-\u003eadd(new RedisChecker('redis:6379'));\n\n$status = $allInOne-\u003egetStatus();\n\nif(!$status-\u003eisUp()) {\n    $this-\u003elogger-\u003ewarn('Something is down', $status-\u003egetError());\n    exit;\n}\n\n// everything is fine\n```\n\n## Available checks\n\n### PDOCheck\n\nIt is just a simple wrapper over [php.PDO](https://www.php.net/manual/en/book.pdo.php).\nIt has the same constructor signature as the `PDO` class. In theory, it works with all\n[PDO drivers](https://www.php.net/manual/en/pdo.drivers.php), but was tested\nonly against MySQL and Postgres.\n\n\n#### Examples\n\n```php\nuse Fullpipe\\CheckThem\\Checks\\PDOCheck;\n\n...\n\n$mysqlCheck = new PDOCheck('mysql:dbname=test_db;host=127.0.0.1:3306', 'username', 'password');\n$pgCheck = new PDOCheck('pgsql:host=localhost;port=8002;dbname=test_db', 'username', 'password');\n```\n\n### HttpCheck\n\nCheck external service by http request. To be `up` service should respond with\n`200` http code.\n\n#### Examples\n\n```php\nuse Fullpipe\\CheckThem\\Checks\\HttpCheck;\n\n...\n\n$userCheck = new HttpCheck('http://user_service:8080/healthz');\n$webCheck = new HttpCheck('https://google.com/');\n```\n\n#### Config\n\n```php\n$check = (new HttpCheck('http://user_service:8080/healthz'))\n    -\u003esetConnectionTimeout(3) // change connection timeout, default 1 second\n    ;\n```\n\n### RedisCheck\n\nChecks redis server with `PING` -\u003e `PONG` request.\n\n#### Examples\n\n```php\nuse Fullpipe\\CheckThem\\Checks\\RedisCheck;\n\n...\n\n$check = new RedisCheck('tcp://10.0.0.1:6379');\n$check = new RedisCheck('unix:/path/to/redis.sock');\n```\n\n#### Config\n\n```php\n$check = (new RedisCheck('redis:6379'))\n    -\u003esetAuth('test_pass') // use password if required\n    -\u003esetConnectionTimeout(4) // timeout for server connection, default 1 second\n    -\u003esetStreamTimeout(3) // timeout for socket read/write operations, default 1 second\n    ;\n```\n\n### PredisCheck\n\nIf you already work with redis using [predis](https://github.com/predis/predis).\nYou could use predis client for `PING` check.\n\n#### Examples\n\n```php\nuse Fullpipe\\CheckThem\\Checks\\PredisCheck;\n\n...\n\n$client = new Predis\\Client([\n    'scheme' =\u003e 'tcp',\n    'host'   =\u003e '10.0.0.1',\n    'port'   =\u003e 6379,\n]);\n$check = new PredisCheck($client);\n```\n\n### SocketCheck\n\nConnects to service and waits for single char from service over a socket connection.\n\n#### Examples\n\n```php\nuse Fullpipe\\CheckThem\\Checks\\SocketCheck;\n\n...\n\n// you could use this check for mysql,\n// it work fine and you don't need a password\n$check = new SocketCheck('mysql:3306');\n```\n\n#### Config\n\n```php\n$check = (new SocketCheck('mysql:3306'))\n    -\u003esetConnectionTimeout(4) // timeout for server connection, default 1 second\n    -\u003esetStreamTimeout(3) // timeout for socket read/write operations, default 1 second\n    ;\n```\n\n### SocketConnectionCheck\n\nChecks only that socket connection is working. It is not the check that you\ncould rely on.\n\n#### Examples\n\n```php\nuse Fullpipe\\CheckThem\\Checks\\SocketConnectionCheck;\n\n...\n\n$check = new SocketConnectionCheck('rabbitmq:5672');\n```\n\n#### Config\n\n```php\n$check = (new SocketConnectionCheck('mysql:3306'))\n    -\u003esetConnectionTimeout(4) // timeout for server connection, default 1 second\n    ;\n```\n\n### AllInOneCheck\n\nChecks all children to be available.\n\n#### Examples\n\n```php\nuse Fullpipe\\CheckThem\\Checks\\AllInOneCheck;\nuse Fullpipe\\CheckThem\\Checks\\SocketCheck;\nuse Fullpipe\\CheckThem\\Checks\\RedisCheck;\n\n...\n\n$check = (new AllInOneCheck())\n    -\u003eadd(new SocketCheck('mysql:3306'))\n    -\u003eadd((new RedisCheck('tcp://10.0.0.1:6379'))-\u003esetAuth('redisPass'))\n    ;\n```\n\n## Test\n\n```bash\ncomposer install\ndocker-compose -f tests/docker-compose.yml up -d\n./vendor/bin/phpunit\n```\n\nor if you want to play with service availability\n\n```bash\ndocker-compose -f tests/docker-compose.yml up -d\nphp ./tests/realtime_test.php\ndocker-compose -f tests/docker-compose.yml restart mysql57\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffullpipe%2Fcheck-them","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffullpipe%2Fcheck-them","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffullpipe%2Fcheck-them/lists"}