Basically this is a starter kit for you to integrate Lumen with JWT Authentication. If you want to Lumen + Dingo + JWT for your current application, please check here.
- Lumen 5.5.
- JWT Auth for Lumen Application. [1]
- Dingo to easily and quickly build your own API. [1]
- Lumen Generator to make development even easier and faster.
- CORS and Preflight Request support.
- FIle System support.
- intervention Image support.
- Clone this repo or download it's release archive and extract it somewhere
- You may delete
.gitfolder if you get this code viagit clone - Run
composer install - Run
php artisan jwt:secret - Configure your
.envfile for authenticating via database - Set the
API_PREFIXparameter in your .env file (usuallyapi).
- Run a PHP built in server from your root project:
php -S localhost:8000 -t public/Or via artisan command:
php artisan serveTo authenticate a user, make a POST request to /api/login with parameter as mentioned below:
Example :
email: johndoe@example.com
password: johndoe
Request:
curl -X POST -F "email=johndoe@example.com" -F "password=johndoe" "http://localhost:8000/api/login"Response:
{
"success": {
"access_token": "a_long_token_appears_here"
"toke_type": "bearer",
"expires_in": microtime
}
}
- With token provided by above request, you can check authenticated user by sending a
GETrequest to:/api/me.
Request:
curl -X GET -H "Authorization: Bearer a_long_token_appears_here" "http://localhost:8000/api/"Response:
{
"success": {
"user": {
"id": 1,
"name": "John Doe",
"email": "johndoe@example.com",
"created_at": null,
"updated_at": null
}
}
}
Laravel and Lumen is a trademark of Taylor Otwell
Sean Tymon officially holds "Laravel JWT" license
If this project help you reduce time to develop, you can give me a cup of coffee :)
