Welcome to the tutorial on setting up Laravel 10 Bootstrap Auth Scaffolding. In this guide, you’ll learn how to create a secure and user-friendly authentication system for your web application using Laravel’s built-in authentication features and Bootstrap for styling. By following the steps below, you’ll have a fully functional authentication system up and running in no time.
Step1: Install Laravel
Begin by installing Laravel 10 by running the following command in your terminal:
composer create-project --prefer-dist laravel/laravel example-app
Step2: Install Laravel UI Package
Next, install the Laravel UI package, which provides the necessary scaffolding for frontend authentication:
composer require laravel/ui
Step3: Generate Authentication System
Generate the authentication system using the Laravel UI package and choose the bootstrap
preset:
php artisan ui bootstrap --auth
This command will set up the authentication scaffolding, including registration, login, and password reset functionalities, all styled with Bootstrap.
Step4: Compile Assets
Compile the frontend assets, including Bootstrap, by running the following command:
npm install && npm run dev
Step5: Run Migrations
Run the migrations to create the necessary database tables for authentication:
php artisan migrate
Step6: Start the Development Server
Start the development server to see your authentication system in action:
php artisan serve
Visit the provided URL in your browser to access the authentication pages.
Step7: Customize Views and Routes
Feel free to customize the generated views located in the resources/views/auth
directory to match your design preferences. Additionally, you can update the authentication-related routes in the routes/web.php
file.
Step8: Protect Routes (Optional)
To protect specific routes for authenticated users only, use the auth
middleware. For instance, to secure the dashboard
route, update the route definition as follows:
Route::get('/dashboard', 'DashboardController@index')->middleware('auth');
Conclusion
Congratulations! You’ve successfully set up Laravel 10 Bootstrap Auth Scaffolding for your web application. By generating the authentication system, integrating Bootstrap, customizing views, and protecting routes, you’ve created a secure and visually appealing authentication experience for your users.
Read More