Package Data | |
---|---|
Maintainer Username: | MKhan777 |
Package Create Date: | 2019-06-26 |
Package Last Update: | 2019-06-28 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2025-02-02 03:04:48 |
Package Statistics | |
---|---|
Total Downloads: | 7 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Please check the official Lumen installation guide for server requirements before you start. Official Documentation
Run the following command in your CMD :
composer create-project talha/lumen-jwt-hashing
Clone the repository form Github
git clone git@github.com:MKhan777/hashing.git
Switch to the repo folder
cd hashing
Install all the dependencies using composer
composer install
Copy the example env file (from lumen sample project.The env file is not pre included in the project)and make the required configuration changes in the .env file
cp .env.example .env
Generate a new application key
Since Lumen doesn't have the php artisan key:generate
command. You can create it online through any
website or create it yourself.
Generate a random App key. Generate a random JWT authentication secret key
Run the database migrations (Set the database connection in .env before migrating)
php artisan migrate
Start the local development server
php -S localhost:8000 -t public
You can now access the server at http://localhost:8000
TL;DR command list
git clone git@github.com:MKhan777/hashing.git
cd lumen-jwt
composer install
cp .env.example .env
Make sure you set the correct database connection information before running the migrations Environment variables
php artisan migrate
php -S localhost:8000 -t public
Populate the database with seed data with relationships which includes users, articles, comments, tags, favorites and follows. This can help you to quickly start testing the api or couple a frontend and start using it with ready content.
Run the database seeder and you're done
php artisan db:seed
Note : It's recommended to have a clean database before seeding. You can refresh your migrations at any point to clean the database by running the following command
php artisan migrate:refresh
** Run composer dump autoload for files autoloading
composer dump-autoload
The code has three basic endpoints get(hash),post(login),post(\register). Use the Postman API builder interface to hit on these urls
/register
provide parameters
{
"name" : "sample",
"email" : "sample@sample.com",
"password" : "sample123"
}
You will get a token in response.
/login
provide parameters
{
"email" : "sample@sample.com",
"password" : "sample123"
}
You will get a token in response.
/hash
provide parameters
{
token : "xyzxvyzsvyz"
}
The same token that has been generated by login or register can be used here for hitting the output will be a hash that,ll be stored in log file
.env
- Environment variables can be set in this fileNote : You can quickly set the database information and other variables in this file and have the application fully working.
Run the Lumen development server
php -S localhost:8000 -t public
The api can now be accessed at
http://localhost:8000/api
Request headers
| Required | Key | Value | |---------- |------------------ |------------------ | | Yes | Content-Type | application/json | | Yes | X-Requested-With | XMLHttpRequest | | Optional | Authorization | Token {JWT} |
Refer the api specification for more info.
This applications uses JSON Web Token (JWT) to handle authentication. The token is passed with each request using the Authorization
header with Token
scheme. The JWT authentication middleware handles the validation and authentication of the token. Please check the following sources to learn more about JWT.