Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

> haddad_zineddine's avatar

API

hello guys , hope u are doing well ,

My question is : which one is the best for API in laravel : Passport or Scantum or JWT ? and can we use fortify package with them ?

0 likes
5 replies
BezhanSalleh's avatar

@jokerdz all of the above, though it depends what do you wanna use the api for?

  1. Passport : Passport provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. It is therefore necessary to have a brief knowledge of OAuth2.

  2. Sanctum : Sanctum it is a simple package to issue API tokens to your users without the complication of OAuth. Also has built-in functionality for SPA authentication.

In a small application use Sanctum. it's simple and easy

  1. JWT : Auth (Authentication) is the process of identifying the user credentials. In web applications, authentication is managed by sessions which take the input parameters such as email or username and password, for user identification. If these parameters match, the user is said to be authenticated.

https://stackoverflow.com/questions/61179166/laravel-auth-vs-passport-vs-sanctum

2 likes
BezhanSalleh's avatar

Depends on the application really, there isn’t any straightforward guide on these sorta things... experience and instinct.

tisuchi's avatar

@jokerdz all of them use for authentication for API, but for different purposes.

For example, we use transport systems like planes, trains, and cars. The main goal for these to move from one place to another but in different scenarios.

In the same approach, we use a passport, sanctum, and JWT. Now you need to know your purpose of use as @bezhansalleh explained.

Now, I would suggest you to understand the authentication flow of API first, then it will make sense to you which one you need based on your purpose.

1 like
> haddad_zineddine's avatar

yes, i want to understand how authentificaion flow of API works , so can you suggest to me a course for that ?

1 like

Please or to participate in this conversation.