Step-by-Step Guide to Creating Your First Laravel CRUD App


Laravel is an elegant framework that simplifies backend development. This tutorial guides you through creating your first CRUD (Create, Read, Update, Delete) application โ a Blog Post Management System. Perfect for beginners and developers looking to refresh their Laravel knowledge.
๐ง Introduction
๐น Why Laravel?
Developer-friendly syntax
Built-in tools (Artisan, Eloquent ORM, Blade templating)
Rapid CRUD development
๐น Project Objective:
Create a Blog Post Manager with full CRUD functionality.
๐น Tech Stack:
Laravel (v10 or latest)
Composer
PHP (โฅ8.1)
XAMPP / Laravel Sail / Valet
๐ง Step 1: Configure Your Laravel Environment
โ๏ธ Install Laravel
composer create-project laravel/laravel blog-crud
cd blog-crud
Or use Laravel Sail for Docker-powered setup:
./vendor/bin/sail up
๐ Set Up Environment
- Edit
.env
file for DB settings:
DB_DATABASE=blog_db
DB_USERNAME=root
DB_PASSWORD=
Create database manually or via migration
Run migrations:
php artisan migrate
๐งฑ Step 2: Generate Model, Migration & Controller
Run one-liner to generate all three:
php artisan make:model Post -mcr
๐ง In database/migrations/xxxx_create_posts_table.php
:
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('body');
$table->timestamps();
});
Run migration:
php artisan migrate
๐ฃ๏ธ Step 3: Configure Routes
In routes/web.php
, register a resource route:
use App\\Http\\Controllers\\PostController;
Route::resource('posts', PostController::class);
This creates all 7 RESTful routes automatically (index
, create
, store
, etc.)
๐ผ๏ธ Step 4: Build Blade Templates
๐น Create a resources/views/posts
directory
๐น Add files: index.blade.php
, create.blade.php
, edit.blade.php
, show.blade.php
Each form should use:
@csrf
@method('PUT') {{-- only for edit --}}
Use route helpers like:
<form action="{{ route('posts.store') }}" method="POST">
๐ง Step 5: Add Controller Logic
Inside PostController.php
:
public function index() {
$posts = Post::all();
return view('posts.index', compact('posts'));
}
public function create() {
return view('posts.create');
}
public function store(Request $request) {
Post::create($request->all());
return redirect()->route('posts.index');
}
public function edit(Post $post) {
return view('posts.edit', compact('post'));
}
public function update(Request $request, Post $post) {
$post->update($request->all());
return redirect()->route('posts.index');
}
public function destroy(Post $post) {
$post->delete();
return redirect()->route('posts.index');
}
๐ Add fillable
fields in Post.php
:
protected $fillable = ['title', 'body'];
โ Step 6: Test Your Application
php artisan serve
Visit: http://127.0.0.1:8000/posts
Perform the full CRUD cycle:
๐ Create
๐ Read
โ๏ธ Update
โ Delete
You've now created a fully functional CRUD app with Laravel!
Next steps for scaling this project:
โ Add form validation (
$request->validate()
)โ Implement Laravel UI or Breeze for authentication
โ Introduce Eloquent relationships (e.g.,
User โ Posts
)โ Deploy via Laravel Forge or Vercel (with APIs)
๐ Supplementary Resources
Subscribe to my newsletter
Read articles from Prashant Dasnur directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Prashant Dasnur
Prashant Dasnur
Iโm an MCA graduate with a passion for building modern web applications.Currently exploring Laravel and React, and sharing my learning journey through blogs and projects.I enjoy solving real-world problems with clean code and creative thinking.Always learning, always building. ๐ป๐