What is Laravel Passport?
Why Interviewers Ask This
This tests whether you can apply Laravel knowledge to real-world scenarios. Interviewers are looking for clarity of thought and evidence that you've encountered this in production code.
Answer
Laravel Passport is a full OAuth2 server implementation for Laravel. It is used when you need OAuth2 capabilities: issuing access tokens for third-party applications, supporting multiple grant types (Authorization Code, Client Credentials, Password, Implicit, Refresh Token), and building a platform where external developers authenticate via your API. Install: composer require laravel/passport, then php artisan passport:install (creates encryption keys and default clients). Issue tokens: $user->createToken("MyApp")->accessToken. Compared to Sanctum: Passport is heavier and appropriate for OAuth2 scenarios where you want to be an OAuth provider (like Google, Facebook). Sanctum is lighter and better for first-party SPAs and mobile apps where you control both the client and server. Most applications should start with Sanctum and add Passport only if they need OAuth2.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.
Previous
What is firstOrCreate and firstOrNew in Eloquent?
Next
What are sub-queries in Laravel Eloquent?