An integral part of most web applications is the user authentication process using a register and login module. In this module, users can register using their credentials and log in with the correct credentials after registering. We'll create a Laravel login and registration page with form validation in this post.
How to create a Laravel Login and Registration page with Form validation
Laravel 8 has an integrated custom authentication system that allows users to log in, register and logout. Consequently, we will develop a custom login and registration system in Laravel.
Below are the steps for creating the login and registration page with form validation:
Step 1: You must first download and install Laravel into your project directory. To install Laravel, simply run the command below from your Windows command prompt:
composer create-project --prefer-dist laravel/laravel login_register |
A new directory, laravelauth, will be created in your Xamp htdocs folder and Laravel files installed inside.
Step 2: After installing laravel, you need to create a MySQL database for storing user data. Launch your PHPMyadmin and create a database Laravel8
Step 3: Now, you need to configure your database settings in your application. Open your .env file and configure your DB_CONNECTION, DB_Host, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD.
Your application is now connected to the database.
Step 4: Now, Open your App\Providers\ AppServiceProvider.php. and paste the code below:
namespace App\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Schema; class AppServiceProvider extends ServiceProvider {
* Register any application services. * * @return void */ public function register() {// }
/** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultstringLength(191); } } |
Step5: Now, in the command prompt, run the command composer require laravel/jetstream.
Step 6: Install livewire using the command php artisan Jetstream: install livewire.
Step 7: Now run npm install and npm run dev
Run npm install
Run npm run dev
Step 8: Migrate the database using the command php artisan migrate. Checking at the database, new tables are formed, and information is inserted.
A new database tables with sample data is generated.
Step 9: We are done with creating a custom Laravel authentication. Run the command php artisan serve to get the project URL. All the three functionalities, login, user register, and form validation, functions well.
Let’s check the three functionalities:
Login form:
Register Form
Form Validation
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register() {// }/**
* Bootstrap any application services.
*
* @return void
*/
public function boot() {Schema::defaultstringLength(191);
}}
Step5: Now, in the command prompt, run the command composer require laravel/jetstream.
Step 6: Install livewire using the command php artisan Jetstream: install livewire.
Step 7: Now run npm install and npm run dev
Run npm install
Run npm run dev
Step 8: Migrate the database using the command php artisan migrate. Checking at the database, new tables are formed, and information is inserted.
A new database tables with sample data is generated.
Step 9: We are done with creating a custom Laravel authentication. Run the command php artisan serve to get the project URL. All the three functionalities, login, user register, and form validation, functions well.
Let’s check the three functionalities:
Login form:
Register Form
Form Validation
-->
Article Contributed By :
|
|
|
|
2073 Views |