islamic-network / microservice-helpers
There is no license information available for the latest version (1.0) of this package.
PHP Package to make microservices consistent
1.0
2019-09-27 12:14 UTC
Requires
- doctrine/dbal: ^2.9
- monolog/monolog: ^2.0
- symfony/yaml: ^4.3
- vesica/cacher: ^1.3
Requires (Dev)
- phpunit/phpunit: ^8.3
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-10-29 05:29:06 UTC
README
This is a group of various PHP helpers that have been extrapolated from the AlAdhan and AlQuran APIs.
They can be used on any projects that use PHP 7.1+.
Current Packages
- A Response helper, which standardizes JSON responses for APIs by including the HTTP code and status in the response itself. See https://api.aladhan.com/v1/gToH, for example.
- Health check monitors for:
- Memcached
- Redis
- MySQL
Installation
composer require islamic-network/microservice-helpers
How to Use to Build a Healthcheck page, for instance
use IslamicNetwork\MicroServiceHelpers\Monitors\Memcached; use IslamicNetwork\MicroServiceHelpers\Monitors\Redis; use use IslamicNetwork\MicroServiceHelpers\Monitors\MySql; use IslamicNetwork\MicroServiceHelpers\Formatters\Response; // Create monitors $memcachedMonitor = new Memcached($host, $port); $redisMonitor = new Redis($host, $port); $mysqlMonitor = new MySql($host, $port); if (!$memcachedMonitor || !$redisMonitor || !$mysqlMonitor) { $httpCode = 500; } else { $httpCode = 200; } Response::build( [ 'memcached' => $memcachedMonitor->status(), 'redis' => $redisMonitor->status(), 'mysql' => $mysqlMonitor->status(), ], $httpCode );