This repository is an API for BMI Calculation using Laravel Lumen Micro-Framework. This project didn't require any database connection.
- PHP >= 7.3
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Composer installed
- Docker installed
- docker-compose installed
- Clone this repo
cd
to this repo and then runcomposer install
- copy .env.example to .env
- run
php -S localhost:80 -t public
- api now accessible locally for development environment
- Clone this repo
cd
to this repo and copy .env.example file into .env file and edit the configuration- in root directory, run
docker-compose up -d
- for the first installation, execute
docker-compose exec bmi-calculation-api composer install
to install the vendor & library - api now accessible locally for development environment
Calculate the BMI and show the Label.
-
URL
/
-
Method
GET
-
URL Params
Field Type Description weight Numeric Weight input in kg height Numeric Height input in cm -
Success Response
HTTP/1.1 200 OK { "bmi":20.6, "label":"normal" }
-
Error Response
HTTP/1.1 422 Unprocessable Entity { "height": ["The input must be a number."] "weight": ["The weight field is required."] }
-
Example
curl 'http://localhost/?height=167&weight=70'
ResponseHTTP/1.1 200 OK { "bmi":25.1, "label":"overweight" }
The stack that used in this image are :
- PHP+apache
- Laravel Lumen
- PaperTrail Centralize Logging
- NewRelic
- Sentry Error Tracking ( Also Integrated with Gitlab )
CI/CD only consist 2 stage :
- build docker image and then push into gitlab container registry
- deploy using docker-compose into server using Gitlab-CI Runner Shell Executor
The deployed container would be 3 container, which is :
- BMI-API Container
- PaperTrail Logging
- Newrelic-Daemon
This API was deployed on this server below
https://bmi.aripratama.com
The container sit behind NGINX reverse proxy
This work is under MIT license.