Convert Figma logo to code with AI

laravel logofortify

Backend controllers and scaffolding for Laravel authentication.

1,599
293
1,599
0

Top Related Projects

Tailwind scaffolding for the Laravel framework.

2,768

Minimal Laravel authentication scaffolding with Blade, Vue, or React + Tailwind.

Associate users with roles and permissions

11,274

🔐 JSON Web Token Authentication for Laravel & Lumen

2,730

Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.

2,514

Laravel UI utilities and presets.

Quick Overview

Laravel Fortify is a frontend agnostic authentication backend for Laravel applications. It provides a set of routes and controllers for handling user authentication, registration, password reset, and other related features, without dictating the frontend implementation.

Pros

  • Flexible and customizable authentication backend
  • Seamless integration with Laravel ecosystem
  • Supports two-factor authentication out of the box
  • Easy to implement with existing Laravel projects

Cons

  • Requires additional frontend work to create a complete authentication system
  • May have a learning curve for developers new to Laravel
  • Limited built-in views, requiring more frontend development
  • Some features may require additional configuration

Code Examples

  1. Customizing password validation rules:
use Laravel\Fortify\Rules\Password;

Fortify::passwordRules(function () {
    return [
        'required',
        'string',
        new Password,
        'confirmed'
    ];
});
  1. Adding custom logic to the login process:
use Laravel\Fortify\Fortify;

Fortify::authenticateUsing(function ($request) {
    $user = User::where('email', $request->email)->first();

    if ($user &&
        Hash::check($request->password, $user->password)) {
        return $user;
    }
});
  1. Customizing the registration process:
use Laravel\Fortify\Fortify;

Fortify::createUsersUsing(CreateNewUser::class);

Fortify::registerView(function () {
    return view('auth.register');
});

Getting Started

  1. Install Laravel Fortify:
composer require laravel/fortify
  1. Publish the configuration file:
php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"
  1. Run migrations:
php artisan migrate
  1. Add Fortify to your config/app.php providers array:
App\Providers\FortifyServiceProvider::class,
  1. Configure Fortify features in app/Providers/FortifyServiceProvider.php:
use Laravel\Fortify\Fortify;

public function boot()
{
    Fortify::registerView(function () {
        return view('auth.register');
    });

    Fortify::loginView(function () {
        return view('auth.login');
    });

    // Add more views and customizations as needed
}

Competitor Comparisons

Tailwind scaffolding for the Laravel framework.

Pros of Jetstream

  • Provides a complete authentication UI out of the box
  • Includes team management functionality
  • Offers two frontend stacks: Livewire and Inertia.js

Cons of Jetstream

  • More opinionated and less flexible than Fortify
  • Steeper learning curve due to additional features
  • Potentially unnecessary features for simpler projects

Code Comparison

Fortify (basic authentication setup):

use Laravel\Fortify\Fortify;

Fortify::registerView(function () {
    return view('auth.register');
});

Jetstream (team creation):

use Laravel\Jetstream\Jetstream;

Jetstream::createTeamsUsing(CreateTeam::class);
Jetstream::updateTeamNamesUsing(UpdateTeamName::class);

Summary

Fortify is a headless authentication backend for Laravel, providing core authentication features without a pre-built UI. It's more flexible and lightweight, allowing developers to implement their own frontend.

Jetstream, built on top of Fortify, offers a complete authentication and team management solution with pre-built UI components. It's more feature-rich but less customizable out of the box.

Choose Fortify for more control over the authentication process and UI, or Jetstream for a quick start with a polished authentication system and team management features.

2,768

Minimal Laravel authentication scaffolding with Blade, Vue, or React + Tailwind.

Pros of Breeze

  • Includes pre-built frontend views and basic styling
  • Offers multiple frontend stack options (Blade, Vue, React)
  • Provides a more opinionated and complete starter kit

Cons of Breeze

  • Less flexible for custom authentication flows
  • May include unnecessary components for simpler projects
  • Requires more setup for API-only applications

Code Comparison

Breeze (Vue.js component):

<template>
    <jet-authentication-card>
        <jet-validation-errors class="mb-4" />
        <form @submit.prevent="submit">
            <!-- Form fields -->
        </form>
    </jet-authentication-card>
</template>

Fortify (PHP implementation):

use Laravel\Fortify\Fortify;

Fortify::registerView(function () {
    return view('auth.register');
});

Fortify::createUsersUsing(CreateNewUser::class);

Breeze provides ready-to-use frontend components, while Fortify focuses on backend authentication logic, allowing developers to implement their own frontend. Breeze is better suited for rapid development of full-stack applications, whereas Fortify offers more flexibility for custom authentication implementations and API-driven applications.

Associate users with roles and permissions

Pros of Laravel Permission

  • More flexible and granular control over roles and permissions
  • Easier to implement complex permission structures
  • Supports caching for improved performance

Cons of Laravel Permission

  • Requires more setup and configuration
  • May be overkill for simple authentication needs
  • Less integrated with Laravel's default authentication system

Code Comparison

Laravel Permission:

$user->givePermissionTo('edit articles');
$user->assignRole('writer');
if ($user->hasPermissionTo('edit articles')) {
    // User can edit articles
}

Fortify:

use Laravel\Fortify\Fortify;

Fortify::authenticateUsing(function ($request) {
    $user = User::where('email', $request->email)->first();
    if ($user && Hash::check($request->password, $user->password)) {
        return $user;
    }
});

Summary

Laravel Permission offers more advanced role and permission management, making it suitable for complex authorization scenarios. It provides fine-grained control and supports caching for better performance. However, it requires more setup and may be excessive for simple authentication needs.

Fortify, on the other hand, is a backend implementation for Laravel's authentication features. It's more tightly integrated with Laravel's default authentication system and easier to set up for basic authentication needs. However, it lacks the advanced permission management features offered by Laravel Permission.

Choose Laravel Permission for complex authorization requirements, and Fortify for simpler authentication needs or when you want to leverage Laravel's built-in authentication features.

11,274

🔐 JSON Web Token Authentication for Laravel & Lumen

Pros of jwt-auth

  • Specialized for JSON Web Token (JWT) authentication
  • Lightweight and focused on a single authentication method
  • Easier integration with mobile and single-page applications

Cons of jwt-auth

  • Limited to JWT authentication, less versatile than Fortify
  • Requires more manual setup and configuration
  • Less integrated with Laravel's ecosystem compared to Fortify

Code Comparison

jwt-auth:

$token = JWTAuth::attempt($credentials);
if (!$token) {
    return response()->json(['error' => 'Unauthorized'], 401);
}
return response()->json(['token' => $token]);

Fortify:

use Laravel\Fortify\Fortify;

Fortify::authenticateUsing(function (Request $request) {
    $user = User::where('email', $request->email)->first();
    if ($user && Hash::check($request->password, $user->password)) {
        return $user;
    }
});

Summary

jwt-auth is a specialized package for JWT authentication in Laravel, offering a lightweight solution ideal for API-centric applications. Fortify, on the other hand, provides a more comprehensive authentication scaffolding with support for various authentication methods. While jwt-auth excels in simplicity for JWT implementations, Fortify offers broader functionality and tighter integration with Laravel's ecosystem. The choice between the two depends on the specific authentication requirements and the overall architecture of your Laravel application.

2,730

Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.

Pros of Sanctum

  • Lightweight and simple API token authentication
  • Supports SPA authentication out of the box
  • Easy integration with mobile applications

Cons of Sanctum

  • Limited built-in features compared to Fortify
  • Requires more manual setup for advanced authentication flows
  • Less opinionated, which may lead to inconsistent implementations

Code Comparison

Sanctum token creation:

$token = $user->createToken('token-name');

Fortify password validation:

use Laravel\Fortify\Rules\Password;

'password' => ['required', 'string', new Password],

Summary

Sanctum is ideal for API-first applications and SPAs, offering a streamlined approach to token-based authentication. It's particularly useful for mobile app integration and stateless authentication scenarios.

Fortify, on the other hand, provides a more comprehensive authentication scaffolding, including features like two-factor authentication and email verification out of the box. It's better suited for traditional web applications with complex authentication requirements.

The choice between Sanctum and Fortify depends on the specific needs of your project, with Sanctum excelling in API-centric applications and Fortify offering a more complete authentication solution for full-stack web applications.

2,514

Laravel UI utilities and presets.

Pros of UI

  • Simpler setup and integration for basic authentication needs
  • Includes pre-built Blade views for login, registration, and password reset
  • Easier to customize views and frontend styling

Cons of UI

  • Less flexible and feature-rich compared to Fortify
  • Lacks advanced authentication features like two-factor authentication
  • Not as well-suited for headless or API-driven applications

Code Comparison

UI (routes/web.php):

Auth::routes();

Fortify (config/fortify.php):

'features' => [
    Features::registration(),
    Features::resetPasswords(),
    Features::emailVerification(),
],

UI focuses on providing a quick setup for authentication with pre-built views, while Fortify offers a more flexible and feature-rich authentication backend. UI is better suited for traditional web applications with server-rendered views, whereas Fortify excels in both traditional and modern, API-driven applications.

UI is easier to get started with and customize visually, but Fortify provides more advanced features and better separation of concerns. Developers should choose based on their project requirements, with UI being ideal for simpler projects and Fortify for more complex authentication needs.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Logo Laravel Fortify

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Fortify is a frontend agnostic authentication backend for Laravel. Fortify powers the registration, authentication, and two-factor authentication features of Laravel Jetstream.

Official Documentation

Documentation for Fortify can be found on the Laravel website.

Contributing

Thank you for considering contributing to Fortify! You can read the contribution guide here.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

Laravel Fortify is open-sourced software licensed under the MIT license.