Lumen PHP Framework
PHPUnit
Mysql 5.7
- web - Web application container (Ubuntu 20.04, php-fpm, nginx, composer)
- db - MySQL container
- test-db - MySQL container for testing.
If docker compose has not been installed, please follow this documentation to install it for your operational system. https://docs.docker.com/compose/install/
- Go to the folder you normally set up projects and run
git clone [email protected]:yao9394/user-microservice.git
- Next, open a new terminal and run
cd user-microservice/
- Run
docker-compose up --build
- Open another terminal in the same folder and run
sudo ./setup.sh
- Visit http://localhost to see the version of Lumen
This application consists of 5 API endpoints
-
List all users Get http://localhost/user
- Response
[ { "id": 1, "name": "Mr. Johnson Strosin", "email": "[email protected]", "created_at": "2021-01-10T14:53:41.000000Z", "updated_at": "2021-01-10T14:53:41.000000Z" }, { "id": 2, "name": "Travon Hartmann", "email": "[email protected]", "created_at": "2021-01-10T14:53:41.000000Z", "updated_at": "2021-01-10T14:53:41.000000Z" }, ]
-
Display a user Get http://localhost/user/1
- Response
{ "id": 1, "name": "Mr. Johnson Strosin", "email": "[email protected]", "created_at": "2021-01-10T14:53:41.000000Z", "updated_at": "2021-01-10T14:53:41.000000Z" }
- Response
-
Add a new user Post http://localhost/user
- Request
{ "name": "test", "email": "[email protected]" }
- Response
{ "name": "test", "email": "[email protected]", "updated_at": "2021-01-10T15:26:58.000000Z", "created_at": "2021-01-10T15:26:58.000000Z", "id": 51 }
- Request
-
Update a user Put/Patch http://localhost/user/update/{id}
- Request (same as Add a new user)
- Response (same as Add a new user)
-
Delete a user Delete http://localhost/user/delete/{id}
- Request (same as Add a new user)
- Response (same as Add a new user)
In a terminal, run
docker exec -it user-microservice_web_1 bash
and then
cd siteroot/
next
root@b76b9e1b8e17:/siteroot/siteroot# vendor/bin/phpunit
PHPUnit 9.5.0 by Sebastian Bergmann and contributors.
...... 6 / 6 (100%)
Time: 00:00.712, Memory: 24.00 MB
OK (6 tests, 76 assertions)