https://github.com/islamic-network/microservice-helpers
A Package to make microservices consistent
https://github.com/islamic-network/microservice-helpers
Last synced: over 1 year ago
JSON representation
A Package to make microservices consistent
- Host: GitHub
- URL: https://github.com/islamic-network/microservice-helpers
- Owner: islamic-network
- License: gpl-3.0
- Created: 2019-09-27T07:24:24.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-29T03:28:18.000Z (about 5 years ago)
- Last Synced: 2025-01-29T12:26:55.190Z (over 1 year ago)
- Language: PHP
- Size: 99.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Islamic Network MicroSevice Helpers
[](https://circleci.com/gh/islamic-network/microservice-helpers)
[](https://packagist.org/packages/islamic-network/microservice-helpers)
[](https://packagist.org/packages/islamic-network/microservice-helpers)
[](https://packagist.org/packages/islamic-network/microservice-helpers)
[](https://packagist.org/packages/islamic-network/microservice-helpers)
[](https://packagist.org/packages/islamic-network/microservice-helpers)
[](https://packagist.org/packages/islamic-network/microservice-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
1. 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.
2. Health check monitors for:
* Memcached
* Redis
* MySQL
## Installation
```
composer require islamic-network/microservice-helpers
```
## How to Use to Build a Healthcheck page, for instance
```php
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
);
```