https://github.com/tarique-iqbal/fruits-and-vegetables
REST API Fruits and Vegetables using Symfony
https://github.com/tarique-iqbal/fruits-and-vegetables
clean-code dto exception-handling rest-api solid symfony symfony6-4
Last synced: 29 days ago
JSON representation
REST API Fruits and Vegetables using Symfony
- Host: GitHub
- URL: https://github.com/tarique-iqbal/fruits-and-vegetables
- Owner: tarique-iqbal
- Created: 2024-08-08T17:04:09.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-12-05T18:09:27.000Z (3 months ago)
- Last Synced: 2024-12-05T19:21:03.905Z (3 months ago)
- Topics: clean-code, dto, exception-handling, rest-api, solid, symfony, symfony6-4
- Language: PHP
- Homepage:
- Size: 193 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🍎 Fruits and 🥕 Vegetables REST API using Symfony
## 🎯 Goal
We want to build a service which will take a `request.json` sample file location: `data/request.json` and:
- Process the file and create two separate collections for `Fruits` and `Vegetables`
- Each collection has methods like `add()`, `remove()`, `list()`;
- Units have to be stored as grams;
- Store the collections in a storage engine of your choice. (e.g. Database)
- Provide an API endpoint to query the collections. As a bonus, this endpoint can accept filters to be applied to the returning collection.
- Provide another API endpoint to add new items to the collections (i.e., your storage engine).
- As a bonus you might:
- consider giving option to decide which units are returned (kilograms/grams);
- how to implement `search()` method collections;
- use latest version of Symfony's to embed your logic## Load json file
Json file loaded via Symfony Console Command
```bash
bin/console app:import-fruit-vegetable path/file.json
```## Routes
`POST /api/fruits`
```json
{
"name": "Apples",
"quantity": 20,
"unit": "kg"
}
````GET /api/fruits | /api/fruits?page=2 | /api/fruits?page=2&unit=kilogram`
`DELETE /api/fruits/{id}`
`POST /api/vegetables`
```json
{
"name": "Carrot",
"quantity": 10922,
"unit": "g"
}
````GET /api/vegetables | /api/vegetables?page=2 | /api/vegetables?page=2&unit=kilogram`
`DELETE /api/vegetables/{id}`
## Running the tests
```shell
$ cd /path/to/base/directory
$ bin/phpunit tests
```