
------------------------------------
Step-by-Step JWT Package Setup
------------------------------------
1. Composer command:
> composer require tymon/jwt-auth
2. Add Provider (/config/app.php):
> Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
3. Add Aliases (/config/app.php):
'Jwt' => Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
4. Publish "jwt.php" file:
> php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
5. Run Migration Command:
> php artisan migrate
6. Generate JWT Secret Token, updates .env file:
> php artisan jwt:secret
7. Update "/config/auth.php", add into guards array:
'api' => [
'driver' => 'jwt',
'provider' => 'users',
],
8. Update User.php (Model):
> Import this, use Tymon\JWTAuth\Contracts\JWTSubject;
> Add with class declaration, "implements JWTSubject"
Add these methods,
public function getJWTIdentifier()
{
return $this->getKey();
}
public function getJWTCustomClaims()
{
return [];
}
9. Great! Now, available middleware "auth:api"
Thank you [ https://jwt-auth.readthedocs.io/en/develop/auth-guard/ ]
Step #1: composer require laravel/passport
Step #2: php artisan migrate
Step #3: php artisan passport:install
Step #4:
Go to Author Model class
>> use Laravel\Passport\HasApiTokens;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthContract;
>> "implements AuthContract"
>> Add "HasApiTokens, Authenticatable"
Step #5:
Open auth.php from /config folder.
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
Go to providers,
'users' => [
'driver' => 'eloquent',
'model' => App\Models\Author::class,
],
Great! you can use middleware for apis: "auth:api"
It is very amazing to work with Laravel framework.
REST stands for Representational State Transfer. A RESTful API uses a set of guidelines that define how the API should be constructed and how it should handle requests and responses.
You will learn the complete idea of Beginners To Advance Laravel 10 APIs Development Tutorials. Basic Experience in Laravel MVC & MySQL required.
Begin your journey of Laravel 10 REST APIs Development with MySQL database driver here.
If you have just decided to learn Laravel concepts to create REST APIs then you have made the right choice, so take a breath. Beginners To Advance Laravel 10 APIs Development Tutorials is very easy to learn which means that you will be through the basics and on to writing standard in a very short time.
Inside this course “Laravel REST APIs Development” you will learn the complete details of Basics of Laravel framework to create web application apis. We will cover the whole basic concept from stage of beginners to creating web apis with authentication in application development.
You’ll get the concept of all building blocks of API Development in Laravel framework via it’s basic sessions of this class.
Overall, inside this well structured of Laravel API Development course you will learn:
– Basics of API Development Using Laravel framework
– Learn about all Database Queries like Insert, Update, Delete, and Select
– Learn about Request and Response flow with calls of APIs
– How To work with CRUD APIs in Laravel
– Queries Handling using Laravel eloquent class
– How To Create RESTful APIs using Sanctum, JWT, Passport Authentication in Laravel framework
– Process of Registration, Login, get Profile data, etc.
– API Development standards of Laravel framework
This course is for every development level. For beginners, it is perfect to enroll and learn development in a detailed way.