Islamic Network MicroSevice Helpers
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
);