Quickstart API REST Doctrine2, PHP7.1, Slim Framework 3 and Authentication with JWT.
Require Composer to run.
In the root, execute:
$ php composer.phar install
Now execute the server php:
$ cd root/public
$ php -S localhost:8080
Name | Route | Verb |
---|---|---|
Login | [localhost:8080/v1/login] | POST |
User | [localhost:8080/v1/register] | GET |
User | [localhost:8080/v1/register] | POST |
Call endpoint register(informed above), to create an account:
{
"name": "Leonardo Farias",
"email": "[email protected]",
"password": "123456"
}
After the account is created, call the login route to get your authentication key.
{
"email": "[email protected]",
"password": "123456"
}
You'll see something like this:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1MDA0Mjc0MTMxsImV4cCI6MTUwMDQzMTAxMywiaWQiOjIsImNsYWltcyI6eyJlbWFpbCI6Imxlb28uZmFyaWFzQGdtYWlsLmNvbSJ9fQ.r1tXQWfURYM7dya06bOENLCqPuiiuCshsnbr1qsUkIW2m8"
}
Now you can use Postman to call users GET endpoint using the token returns.
Key | Value |
---|---|
Authorization | BEARER {{token}} |
If you have any questions, please contact: [email protected]