Recall & Review
beginner
What is an authentication guard in Laravel?
An authentication guard in Laravel is a way to define how users are authenticated for each request. It controls how users are retrieved and how their credentials are checked.
Click to reveal answer
beginner
Name two common types of guards in Laravel.
The two common types of guards in Laravel are 'session' guard, which uses sessions and cookies, and 'token' guard, which uses API tokens for stateless authentication.
Click to reveal answer
intermediate
How do you specify which guard to use in Laravel?
You specify the guard by passing its name to the auth() helper or using the 'guard' method, like auth()->guard('web') or auth('api').
Click to reveal answer
beginner
Where are guards configured in a Laravel project?
Guards are configured in the 'config/auth.php' file under the 'guards' array. Each guard defines its driver and provider.
Click to reveal answer
intermediate
What is the role of a user provider in Laravel authentication guards?
A user provider defines how users are retrieved from storage, like a database. Guards use providers to fetch user data for authentication.
Click to reveal answer
Which file in Laravel contains the configuration for authentication guards?
✗ Incorrect
The 'config/auth.php' file holds the configuration for authentication guards in Laravel.
What does the 'session' guard in Laravel use to keep users logged in?
✗ Incorrect
The 'session' guard uses cookies and sessions to maintain user login state.
How do you access the 'api' guard in Laravel code?
✗ Incorrect
You access a specific guard by passing its name to the auth() helper, like auth('api').
What is the main purpose of a user provider in Laravel authentication?
✗ Incorrect
User providers define how user data is fetched from storage, such as a database.
Which guard type is best for stateless API authentication?
✗ Incorrect
Token guards are used for stateless API authentication, often using API tokens.
Explain what an authentication guard is in Laravel and how it works with user providers.
Think about how Laravel checks who a user is and where it gets user info.
You got /3 concepts.
Describe how you would configure and use multiple guards in a Laravel application.
Consider a site with both web users and API users needing different login methods.
You got /3 concepts.