📜  laravel make:auth - PHP (1)

📅  最后修改于: 2023-12-03 14:43:45.535000             🧑  作者: Mango

Laravel Make:Auth

Laravel Make:Auth is a command that generates a complete authentication system with ready-to-use views and controllers in a Laravel application.

Requirements
  • Laravel installed on your system
  • Composer installed on your system
Usage

To generate the authentication system, run the following command in your terminal:

php artisan make:auth

This command will generate all the necessary files, including the Auth controllers and views.

Benefits

By using Laravel Make:Auth, you can save a lot of time and effort while developing your Laravel application. You don't need to manually create and code the authentication system, as Laravel does it for you.

This authentication system comes with pre-built templates, which means you don't need to worry about the front-end design. Additionally, Laravel Make:Auth is highly customizable, which means you can easily modify the authentication system to fit your specific application's requirements.

Code Example

Here is an example of a login form generated by Laravel Make:Auth:

@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header">{{ __('Login') }}</div>

                    <div class="card-body">
                        <form method="POST" action="{{ route('login') }}">
                            @csrf

                            <div class="form-group row">
                                <label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

                                <div class="col-md-6">
                                    <input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>

                                    @error('email')
                                        <span class="invalid-feedback" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            </div>

                            <div class="form-group row">
                                <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

                                <div class="col-md-6">
                                    <input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">

                                    @error('password')
                                        <span class="invalid-feedback" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            </div>

                            <div class="form-group row">
                                <div class="col-md-6 offset-md-4">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>

                                        <label class="form-check-label" for="remember">
                                            {{ __('Remember Me') }}
                                        </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group row mb-0">
                                <div class="col-md-8 offset-md-4">
                                    <button type="submit" class="btn btn-primary">
                                        {{ __('Login') }}
                                    </button>

                                    @if (Route::has('password.request'))
                                        <a class="btn btn-link" href="{{ route('password.request') }}">
                                            {{ __('Forgot Your Password?') }}
                                        </a>
                                    @endif
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
Conclusion

Laravel Make:Auth is a powerful command that simplifies the authentication system's creation in Laravel applications. It saves time and effort and supports customization to suit your application's specific requirements.