Template for a lightweight PHP micro-service to record and expose per-country usage statistics.
Build containers, install PHP dependencies, and start the stack:
make upcurl -X POST http://127.0.0.1:8088/v1/statistics \
-H "Content-Type: application/json" \
-d '{"countryCode": "ru"}'Response:
201 Created
Wrong country code example:
curl -X POST http://127.0.0.1:8088/v1/statistics \
-H "Content-Type: application/json" \
-d '{"countryCode": "wrongCountry"}'Response:
201 Created
curl -X GET http://127.0.0.1:8088/v1/statistics \
-H "Content-Type: application/json"Response:
{
"ru": 813,
"us": 456,
"it": 92,
"de": 17,
"cy": 123
}Execute the full PHPUnit suite:
make unit-testmake load-test