FoodIST server module, providing a REST API HTTPS server for Mobile and Ubiquitous Computing class @ Instituto Superior Técnico, Lisbon, Portugal.
Meant to be used with the FoodIST Android application, it provides the ability to crowdsource cafeteria menus, dishes pictures and queue wait times.
More information: https://fenix.tecnico.ulisboa.pt/disciplinas/CMov4/2019-2020/2-semestre
Group 23
- Fetch cafeterias
- Fetch menus
- Fetch/add/delete/update the queue wait duration for each user
- Fetch/add/delete/update dishes
- Fetch/add/delete picture dishes
- Supports SSL/TLS if your webserver is configured accordingly
For usage, please read How to use / Endpoints.
This project is deployed on https://data.florianmornet.fr/api/, feel free to give it a try!
- Add authentication
This web application is written in PHP 7, built around Silex micro-framework for routing (lighter than the whole Symfony package).
Data are stored in a MySQL database and can be updated using HTTP methods.
- A web server, can be Apache, nginx...
- PHP >=7.2.5
- A MySQL/MariaDB database
- Composer >=1.6.0
- Run
composer install
. - Setup the utils/PictureUploader.php to define where the dish pictures will be stored.
- Setup the utils/Database.php using your database connexion data.
- Then, load the init.sql script in your corresponding database (eg:
mysql -u root -p foodist < init.sql
). - Finally, configure your web server as following
- Check that your Apache configuration (eg:
/etc/apache2/apache2.conf
) hasAllowOverride
set toAll
for your server Directory - Use the provided .htaccess, and modify the
FallbackResource
rule according to the absolute app path
https://silex.symfony.com/doc/2.0/web_servers.html
The server will be started on https://localhost/, which is also the default base API URL (if deployed in a subdirectory, do not forget to update the .htaccess file and utils/PictureUploader.php accordingly).
Method | Endpoint | Example |
---|---|---|
GET | /api/cafeterias | /api/cafeterias |
GET | /api/cafeterias/{id} | /api/cafeterias/1 |
GET | /api/cafeterias/{id}/beacons | /api/cafeterias/1/beacons |
GET | /api/cafeterias/{id}/dishes | /api/cafeterias/1/dishes |
Method | Endpoint | Example |
---|---|---|
GET | /api/beacons | /api/beacons |
POST | /api/beacons | {"cafeteria_id": 12, "datetime_arrive": "2020-04-26T09:12:43.511Z"} |
GET | /api/beacons/{id} | /api/beacons/1 |
PUT | /api/beacons/{id} | {"datetime_leave": "2020-04-26T09:12:43.511Z"} |
Method | Endpoint | Example |
---|---|---|
GET | /api/dishes | /api/dishes |
POST | /api/dishes | {"cafeteria_id": 12, "name": "Bacalhau à brás", "price": 1.4}, "have_info": true,"meat": false, "fish": true, "vegetarian": false, "vegan": false, "dietary_data": "This contains fish" |
GET | /api/dishes/{id} | /api/dishes/1 |
PUT | /api/dishes/{id} | {"cafeteria_id": 2, "name": "Soup", "price": 0.8} |
DELETE | /api/dishes/{id} | /api/dishes/1 |
GET | /api/dishes/{id}/pictures | /api/dishes/1/pictures |
Method | Endpoint | Example |
---|---|---|
GET | /api/pictures | /api/pictures |
GET | /api/pictures/first | /api/pictures/first |
POST (multipart/form-data) | /api/pictures | {"dish_id": 12, "picture": <JPEG file>} |
GET | /api/pictures/{id} | /api/pictures/1 |
DELETE | /api/pictures/{id} | /api/pictures/1 |
-
REST basics in PHP:
-
How to upload a file using a REST web service:
-
REST JSON auth:
-
MySQL and JSON date formats:
-
Queuing theory