How to Create Login and Signup Page in Laravel in 10 Simple Steps

Laravel is a free and open-source PHP framework that simplifies the development of modern web applications. It’s sort of like a toolbox and set of shortcuts to help developers write clean, secure, and organized code without having to reinvent the wheel every time. It comes with built-in support for features such as routing, authentication, databases, and templating, so you can focus more on building your app and less on configuring everything from scratch.

To create a web Application in Laravel, you need to have a login and signup page so that users can engage with the site. Make those pages as simple as possible. In this article, we will discuss how to create Login and Signup pages and pass user data to the database. Before making these pages, you need to have Laravel running on your system and have a project ready.

10 Steps to Create a Laravel Project on Windows Devices

Install Laravel Breeze and Create Register and Login Page

Breeze is a starter kit that gives you everything you need to build user authentication in a Laravel app, without the complexity. This involves Login and Registration pages, and also includes an email reset option. To install Breeze, open the command prompt in your project root directory.

 

Step 1:  After that, you need to run some commands to install this starter kit in your project. Make sure to run all these commands step by step.

composer require laravel/breeze –dev
php artisan breeze:install
php artisan migrate
npm install
npm run build

While running the second code you will encounter a selection step where you need to choose which Breeze stack you want to download. From there, choose Blade. And select Pest in the testing network.

Laravel Breeze install

Step 2: After running the second command, you have to open your Text editor program and head over to Database>migrations>user_table.php. Ensure your database is ready and has been added to the code. After that, add some code for user type, and below that, any field you need. In my case, I’m going with a phone number. The code should look like the image below.

user table migration laravel

Step 3: Next, navigate to app/models/User.php and add the new field that you added to the user table. In my case, I’ve added the phone field.

User.php model for laravel

Step 4: Run the third command, which is for Migration.

migration for laravel login page

Step 5: Run the last two commands

Step 6: Now, refresh your Laravel site, and you will see the Login and Register buttons at the top.

Register page appears in laravel

Step 7: Now open resources\views\auth\register.blade.php and add new fields that you added to the database earlier. (Bonus tip: Hold Ctrl and select all the parts together to edit them at once)

Step 8: Add the new fields in the Controller for this head to app\Http\Controllers\Auth\RegisteredUserController.php and add those fields.

Step 9: Open your site and check the registration page by creating a New account, then verify your database.

Step 10: Congratulations, your register page has now been completed. You can add as many fields as you need in your registration form.

 

In conclusion

This article was about how to create a Register and login page in Laravel using the Breeze start-up kit. I hope this guide was helpful.

 

Thanks for Visiting Code Issue Hub

 

1 thought on “How to Create Login and Signup Page in Laravel in 10 Simple Steps”

Leave a Comment