In this project i'm working with laravel 5.6
Specs and guides can be found on following link:
https://laravel.com/docs/5.6
- PHP >= 7.1.3
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
- Ctype PHP Extension
- JSON PHP Extension
If you want to install laravel from scratch follow the readme of this repository:
https://github.com/Trapn/laravelframeworktesting (there is a little tutorial for laravel blade templating and presetting react)
If you want to use mySQL create a database called: smartcampus
Run this command in powershell to create the database tables:
php artisan migrate
The output should look like this:
To "seed" (or fill) the database with dummy info:
php artisan db:seed
The output should look like this:
ONLY if you did something wrong with adding info to the database run this before seeding:
php artisan migrate:fresh
(this will delete all tables and make them again)
https://projectwerk2.herokuapp.com/
If you run this local you can start the server by:
php artisan serve
The app can be found on:
http://localhost:8000/
If the api is indicated with a 🔐 you need an account to use the api (see register and login down below how to acces thes api routes)
- /api/listener (POST REQUEST to post multiple measurements)
the format should look like this:
There's a dummy device in the database with dev-eui 00E4F052209EE8A5
the json should look like this:
{
"dev_eui": "00E4F052209EE8A5",
"temperature": 5,
"humidity": 20,
"movement": 8
}
to check if the measurements are added you can check:
api/measurements (GET REQUEST)
- /api/locations/{id}
- /api/locations (GET REQUEST returns all locations)
- /api/locations 🔐 (POST REQUEST posts a new locations)
the format for postings should look like this:
{
"name": "theNameOffTheClassroom",
"roomnumber": "theNumberOfftheClassroom(the datatype is a string)",
"description": "theDescriptionOffTheClassroom"
}
- /api/devices/{id}
- /api/devices (GET REQUEST returns all devices)
- /api/devices 🔐 (POST REQUEST posts a new devices)
the format for postings should look like this:
{
"name": "theNameOffTheDevice",
"dev-eui": "theDev-euiOffTheDevice",
"location_id": "PKoffTheLocationWhereTheDeviceIsLocated"
}
- /api/sensors/{id}
- /api/sensors (GET REQUEST returns all sensors)
- /api/sensors 🔐 (POST REQUEST posts a new sensors)
the format for postings should look like this:
{
"name": "theNameOffThesensor",
"measurement_unit": "theUnitTheSensorIsMeasuring",
"device_id": "PKoffTheDeviceWhereTheSensorIsInstalled"
}
JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA.
This is an example to register or login with a user to access the 🔐 API's. In this example i'm using POSTMAN you can download it here:
https://www.getpostman.com/
To register you can simply add some Params to you're request:
After registering you can get the token by logging in:
When done the previous steps you have to add some things to you're request
- /api/locations 🔓
- /api/devices 🔓
- /api/sensors 🔓
- /api/measurements 🔓
Make sure the Foreign key(if adding devices, sensors, measurements) of the other table exists.
You should get something like this when sending the post request:
You can run all artisan commands on heroku:
heroku run php /app/artisan migrate