intermediateLaravel
Previous
What is the difference between authentication and authorization?
Next
What are gates and policies?
What are guards and providers?
Answer
Clear, interview-ready explanation
Guards define how Laravel authenticates a request. For example, the session guard maintains authentication with sessions and cookies, while an API guard may authenticate with a token or another request-based mechanism.
Providers define how Laravel retrieves user records from persistent storage. Laravel includes Eloquent and database query-builder providers, and applications can add custom providers when needed. Guards and providers are configured in config/auth.php, allowing one application to support different user types or authentication mechanisms.