Build a simple API with Lumen Framework. This application already implementation JWT for authorization and UUID identifier ID.
- PHP ^8.0
- Lumen ^9.0
- MySql 8.0
- click use this template
- composer install
- copy
.env.example
to.env
- set
APP_KEY
execute command :
php artisan key:generate
- set env variable :
DB_DATABASE=<your database>
DB_USERNAME=<your username>
DB_PASSWORD=<your password>
- set config file:
auth.php.example -> auth.php
jwt.php.example -> jwt.php
logging.php.example -> logging.php
- set configuration as your needs
- for
JWT_SECRET
section by run :
php artisan jwt:secret
php artisan migrate --seed
php -S lumen:8000 -t public
- open postman or insomnia
- create new request authentication
- add name Login,
- method POST
- url http://localhost:8080/api/auth/login
- add header
- Content-Type = application/json
- add body json
{
"email": "[email protected]",
"password": "12345678"
}
- create new request profile
- add name Me,
- method GET
- url http://localhost:8080/api/profile/me
- add header
- Content-Type = application/json
- Authorization = bearer {ACCESS_TOKEN}
- Next
do the same thing as request profile for post and todo service.