This is a tiny example of using MongoDB + Lumen together to store a person and their birthday.
For ease of running the project, I have included the .env in the repository; this would normally be left out.
Main points of interests will be:
There were no dependencies added besides MongoDB Eloquent Provider
A Dockerfile is provided to provide the MongoDB extension to the php:8 image
docker-compose up
Start the project as above, then run the following command:
docker exec -it api ./vendor/bin/phpunit
This project is very bare bones; it could be improved in a few ways:
- Distribution - Currently the built in PHP web server is being used, this is not suitable for a production deployment. Depending on the deployment, a new docker container should be created with a webserver base.
- Dependency Injection - BirthdayCalculator could probably be better implemented with dependency injection, but for the sake of time I have left it as is
- Further Tests - More tests could be added for the Person model, and the PeopleController