Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Auth Laravel Package

illuminate/auth

Laravel’s authentication component providing guards, user providers, password hashing, “remember me” services, and authorization gates. Powers login/session auth and integrates with HTTP middleware and the framework’s auth configuration.

Deep Wiki
Context7

Getting Started

  • This package is a read-only subtree split of the authentication system from laravel/framework, and is not meant for standalone usage.
  • Begin by installing the full laravel/framework (e.g., via composer require laravel/framework), which includes illuminate/auth.
  • Authentication is configured in config/auth.php, with guards, providers, and password reset settings.
  • The first use case is protecting routes: middleware like auth (via Auth::routes() or manually in routes/web.php) enforces authentication checks on routes.

Implementation Patterns

  • Use the Auth facade or Illuminate\Support\Facades\Auth Facade for convenient interaction:
    // Check if user is authenticated
    if (Auth::check()) { /* ... */ }
    
    // Get current user
    $user = Auth::user();
    
    // Attempt login with credentials
    if (Auth::attempt(['email' => $email, 'password' => $password])) { /* ... */ }
    
  • Extend or override guards/providers in config/auth.php (e.g., using JWT, OAuth, or custom database-based guards).
  • For API token-based auth, combine laravel/passport or laravel/sanctum (they extend illuminate/auth under the hood).
  • Custom authentication logic often lives in App\Services\Auth or request classes (e.g., custom Authorizable traits, pivot-role checks).
  • Use Auth::guard('name') to explicitly reference guards, especially when using multiple providers (e.g., web, api, sanctum).

Gotchas and Tips

  • DO NOT require this package directly — it's deprecated for direct dependency usage; always use laravel/framework instead.
  • Auth::user() returns null silently if unauthenticated — always check with Auth::check() or use middleware (auth:web) to avoid null dereference bugs.
  • Session-based login (web guard) requires StartSession middleware enabled — a common pitfall in Lumen or minimal setups.
  • If using custom user models, ensure they implement AuthenticatableContract (or extend Illuminate\Foundation\Auth\User).
  • For debugging login failures, check Auth::errors() (via the guard) and inspect config/auth.php for correct provider mapping (providers.users.model).
  • To override password validation or reset logic, extend AuthServiceProvider and hook into Auth::extend() or use custom PasswordBroker logic.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport