wandersonwhcr / rest-romans
The Most Unuseful Web Service to Convert Roman Numerals to Arabic and Vice Versa
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 7
Type:project
Requires
- php: >=7.4
- psr/http-message: 1.0.*
- slim/psr7: 1.3.*
- slim/slim: 4.7.*
- wandersonwhcr/romans: ^1.0
Requires (Dev)
- php-parallel-lint/php-parallel-lint: 1.2.*
- phpmd/phpmd: 2.9.*
- phpunit/phpunit: 9.5.*
- sebastian/phpcpd: 6.0.*
- slevomat/coding-standard: 6.4.*
- squizlabs/php_codesniffer: 3.5.*
This package is auto-updated.
Last update: 2024-11-29 06:35:41 UTC
README
The Most Unuseful Web Service to Convert Roman Numerals to Arabic and Vice Versa
Description
This project provides a RESTful service to convert Roman numerals to Arabic and Arabic numerals to Roman. Simple as it is. Also, it is written using PHP and Romans library.
Installation
You can build this service from source, but there is a Docker image ready to use. That image is based on PHP-FPM and you must use a HTTP service as sidecar, like NGINX.
cat > default.conf.template <<'EOF' server { listen 80; root /var/www/html/public; index index.php; try_files $uri $uri/ /index.php; location ~* \.php$ { fastcgi_pass romans:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } } EOF docker network create romans docker run \ --detach \ --name romans \ --network romans \ --publish 9000 \ wandersonwhcr/romans docker run \ --detach \ --name romans-http \ --network romans \ --publish 80:80 \ --volume "`pwd`/default.conf.template:/etc/nginx/templates/default.conf.template" \ nginx
Docker Compose
Also, you can use docker-compose
to execute this service. Please, remember to
create default.conf.template
file from the previous section.
version: "3" services: romans: image: "wandersonwhcr/romans" networks: - romans ports: - "9000" romans-http: image: "nginx" networks: - romans ports: - "80:80" volumes: - "./default.conf.template:/etc/nginx/templates/default.conf.template" networks: romans:
Usage
As a RESTful service, it makes available two endpoints for convertions. Next
example uses curl
to send a request to convert 1999
from Arabic numeral to
Roman.
curl http://localhost/v1/arabics/1999 \
--include \
--request GET \
--header 'Accept: application/json'
HTTP/1.1 200 OK
Content-Type: application/json
{"arabic":"1999","roman":"MCMXCIX"}
There is another endpoint to convert from Roman numeral to Arabic as next example.
curl http://localhost/v1/romans/MCMXCIX \
--include \
--request GET \
--header 'Accept: application/json'
HTTP/1.1 200 OK
Content-Type: application/json
{"arabic":"1999","roman":"MCMXCIX"}
Development
You can use Docker Compose to build images from this project and run a container to develop and test this package.
docker-compose build
docker-compose run php-fpm composer install
docker-compose run php-fpm composer test
License
This project is opensource and available under MIT license described in LICENSE.