To start a server, run from root directory
$ cd public
$ php -S localhost:8000
// or
$ php artisan serve
To run tests
$ php artisan test
Once the server is up and running, you can migrate tables and generate fake data by running
$ php artisan migrate --seed
$ curl --header "Accept: application/json" --header "Content-Type: application/json" --request POST --data '{"name": "John Doe", "email": "[email protected]", "password": "1234", "password_confirmation": "1234"}' http://localhost:8000/api/users
And to log in
$ curl --header "Accept: application/json" --header "Content-Type: application/json" --request POST --data '{"email": "[email protected]", "password": "1234"}' http://localhost:8000/api/login
For subsequent order requests, you must include the API Token generated from the login request
{
"token": "<ACCESS_TOKEN>"
}
$ curl --header "Accept: application/json" --header "Content-Type: application/json" --request POST --data '{"title": "New Product", "price": 2499, "count": 5}' http://localhost:8000/api/products
$ curl --header "Accept: application/json" --header "Content-Type: application/json" --header "Authorization: Bearer <ACCESS_TOKEN>" --request POST --data '{"items": [{"product_id": 1, "quantity": 1}]}' http://localhost:8000/api/orders
Licensed under the MIT license
.