/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
We are the best world Information Technology Company. Providing the highest quality in hardware & Network solutions. About more than 25 years of experience and 1000 of innovative achievements.
Laravel is a powerful PHP framework that provides an elegant way to handle authentication. In this guide, we will walk you through setting up authentication in a Laravel 10 project.
Prerequisites
Before you begin, ensure you have the following:
PHP >= 8.1 installed on your system.
Composer installed.
A new or existing Laravel 10 project.
Step 1: Install Laravel Project
If you don’t already have a Laravel 10 project, create a new one:
Laravel Breeze is a minimal and simple implementation of authentication. Run the following command to install Breeze:
composer require laravel/breeze --dev
After installation, publish the Breeze scaffolding:
php artisan breeze:install
By default, Breeze uses Blade templates. If you prefer Inertia.js (Vue or React), specify the stack during installation. For example:
Vue:
php artisan breeze:install vue
React:
php artisan breeze:install react
Step 3: Install Dependencies
Once Breeze is installed, run the following commands to install front-end dependencies and build the assets:
npm install npm run dev
Step 4: Migrate the Database
Make sure your .env file is properly configured with your database connection. Then, run the migrations to create the required authentication tables:
php artisan migrate
Step 5: Serve Your Application
Run the development server to view your application:
php artisan serve
Visit http://127.0.0.1:8000 in your browser. You should see the login and registration pages ready to use.
Optional Steps
1. Customize Authentication Views
The authentication views are located in the resources/views/auth directory. You can modify these files to match your design requirements.
2. Customize User Model
If you need additional fields for users, you can modify the users table migration file in database/migrations and the User model in app/Models/User.php.
3. Middleware
Laravel automatically applies the auth middleware to routes requiring authentication. You can manage this in the routes/web.php file.
For example: Route::middleware(['auth'])->group(function () { Route::get('/dashboard', function () { return view('dashboard'); })->name('dashboard'); });