PHP code example of quvel / auth

1. Go to this page and download the library: Download quvel/auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

quvel / auth example snippets


'prefix' => 'auth',  // Routes at /auth/*
'views' => false,    // API-only mode

'features' => [
    Features::registration(),
    Features::resetPasswords(),
    // Features::emailVerification(),
    Features::updateProfileInformation(),
    Features::updatePasswords(),
    Features::twoFactorAuthentication([
        'confirm' => true,
        'confirmPassword' => true,
    ]),
],

// Our AuthServiceProvider automatically binds these:

// Fortify uses our custom CreateNewUser action
$app->singleton(CreatesNewUsers::class, CreateNewUser::class);

// Fortify uses our JSON LoginResponse instead of redirects
$app->singleton(LoginResponseContract::class, LoginResponse::class);

// etc.

'features' => [
    Features::registration(),           // POST /auth/register
    Features::resetPasswords(),         // POST /auth/forgot-password, etc.
    Features::emailVerification(),      // Email verification routes
    Features::updateProfileInformation(), // PUT /auth/user/profile-information
    Features::updatePasswords(),        // PUT /auth/user/password
    Features::twoFactorAuthentication(), // All 2FA routes
],

'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => env('GOOGLE_REDIRECT_URI'),
],

'socialite' => [
    'enabled' => false,
],

use Illuminate\Support\Facades\RateLimiter;

RateLimiter::for('login', fn ($request) =>
    Limit::perMinute(10)->by($request->email . $request->ip())
);

// app/Http/Responses/CustomLoginResponse.php
class CustomLoginResponse implements LoginResponseContract
{
    public function toResponse($request): JsonResponse
    {
        return response()->json([
            'user' => $request->user()->load('roles'),
            'permissions' => $request->user()->getAllPermissions(),
        ]);
    }
}

$this->app->singleton(
    \Laravel\Fortify\Contracts\LoginResponse::class,
    \App\Http\Responses\CustomLoginResponse::class
);

$this->app->singleton(
    \Laravel\Fortify\Contracts\CreatesNewUsers::class,
    \App\Actions\Fortify\CreateNewUser::class
);

'routes' => [
    'enabled' => false,
],
bash
composer fortify:install
php artisan sanctum:install
php artisan migrate
bash
php artisan vendor:publish --tag=quvel-auth-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=quvel-auth-routes
bash
php artisan route:list --path=auth
bash
php artisan config:clear