==============================
This example follow DDD approach. It is maintainable and we can write our tests easily.
We use Slim Framework in this example.
- Slim Framework
- Doctrine ORM
cd /path/to/project/folder
composer install
mysql -u username -p dbname /path/to/project/folder/dump/basic-rest.sql
location / {
...
fastcgi_param APPLICATION_ENV development; #APPLICATION_ENV = development
...
}
nano /path/to/project/folder/src/Application/config/development.yaml
curl -X POST \
http://your.host/offer \
-H 'content-type: application/json' \
-d '{"name": "Some amazing offer", "discount": 25}'
curl -X POST \
http://your.host/recipient \
-H 'content-type: application/json' \
-d '{"name": "John Doe", "email": "[email protected]"}'
curl -X POST \
http://your.host/generateVouchers \
-H 'content-type: application/json' \
-d '{"offerId": 1, "expiration": "2017-12-31"}'
curl -X POST \
http://your.host/useVoucher \
-H 'content-type: application/json' \
-d '{"code": "someAmazingCode", "email": "[email protected]"}'
curl -X POST \
http://your.host/getVouchers \
-H 'content-type: application/json' \
-d '{"email": "[email protected]"}'
- You can find Postman collection in the dump folder 🎁
- Extract routes to own file
- Extract response creating to own class
- Implement auth middleware
- Implement validation for request (never believe to user)
- Write unit tests
- Remove dump & implement Phinx for db migrations