Tutorial Create Make Feature Login & Register with Laravel 10
Hello Medium Readers,
Welcome to Our Laravel 10 Login and Register Project!
Get ready to explore Laravel 10 with our hands-on login and register project! In this concise guide, we’ll walk you through the process of creating secure and user-friendly login and register functionalities. Whether you’re a beginner or an experienced developer, you’ll quickly master these essential skills.
Let’s start coding!
Presented by:
1. Ilaikal Fathurrahman (Front-end Development)
2. Kerin Al Ramadhan Fika (Back-end Development)
3. Seto Prasetyo (UI/UX Designer)
Certainly, here are the steps for creating a basic login and register project using Laravel 10:
Step 1: Installation
1. Ensure you have PHP, Visual Studio Code and Composer installed on your system. Optional(Use git if you have Github account)
2. Open the terminal and run the following command to create a new Laravel project:
composer create-project --prefer-dist laravel/laravel Project10laravel
3. Navigate to the project directory using cd project-name
.
example:
then use command code . on your terminal to open laravel project.
Step 2: Database Configuration
- Create a new database on your MySQL or PostgreSQL server.
- Configure the database connection in the
.env
file by filling in details such as the DB_DATABASE, DB_USERNAME, and DB_PASSWORD.
You can leave the username and password (root) blank if you are using the XAMPP application
Example:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:QCGBF0z7kFnNegFygBMJzQbsiTAzmF9DRPnBE3a37N0=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laraveldb
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_APP_NAME="${APP_NAME}"
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Step 3: Create Model and Migration
1. Create a model for users with the Artisan command:
php artisan make:model User -m
2. Open the newly created migration file in the database/migrations
directory and add the necessary columns for login and register (e.g., name
, email
, password
).
3. Run the migration to create the users table in the database:
php artisan migrate
Step 4: Controller Creation
1. Create a controller for login and register:
php artisan make:controller AuthController
2. Implement login and register logic inside the controller according to your application requirements.
Step 5: Define Routes
1. Define routes for login and register in the routes/web.php
or routes/api.php
file.
Example:
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\HomeController;
Route::get('/', function () {
return view('welcome');
});
Route::group(['middleware' => 'guest'], function () {
Route::get('/register', [AuthController::class, 'register'])->name('register');
Route::post('/register', [AuthController::class, 'registerPost'])->name('register');
Route::get('/login', [AuthController::class, 'login'])->name('login');
Route::post('/login', [AuthController::class, 'loginPost'])->name('login');
});
Route::group(['middleware' => 'auth'], function () {
Route::get('/home', [HomeController::class, 'index']);
Route::delete('/logout', [AuthController::class, 'logout'])->name('logout');
});
Step 6: Create Views
1. Create views (blade templates) for the login and register pages inside the resources/views
directory.
2. Design and implement the user interface according to your project requirements.
Example:
Step 7: Testing and Debugging
- Test the application by filling out the login and register forms. BY using code:
php artisan serve
Click the server address http://127.0.0.1:8000 and use command by follow this code http://127.0.0.1:8000/login and
for register page http://127.0.0.1:8000/register
These are the basic steps for creating a login and register project using Laravel 10. Of course, you can customize and expand upon these steps based on your project’s requirements and complexity.
Happy coding!
Here is our source if you want to create a Laravel project as well:
https://github.com/Zhenzun/Tutorial_Buat_Login_register.git