A simple implementation of JWT authentication in Laravel using the tymon/jwt-auth package.
-
Clone the repository:
git clone https://github.com/bailyboy021/Laravel-JWT.git
-
Navigate to the project directory:
cd Laravel-JWT
-
Install Composer dependencies:
composer install
-
Copy the
.env.example
file to.env
and configure your environment variables (especially database credentials):cp .env.example .env
Buka file
.env
dan sesuaikan pengaturan database Anda. Contoh:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_jwt DB_USERNAME=root DB_PASSWORD=
-
Generate JWT secret key:
php artisan jwt:secret
This command will generate a JWT secret key and add it to your
.env
file asJWT_SECRET
. -
Generate application key:
php artisan key:generate
-
Run database migrations:
php artisan migrate
-
Serve the application:
php artisan serve
This will start the development server at
http://127.0.0.1:8000
.