Laravel
PHP web framework for building modern, robust, and secure web applications
Lessons
- What is Laravel?
- MVC Structure
- Defining Routes
- Creating a Controller
- Blade Templates
- Database Migrations
- Eloquent ORM
- Authentication
- Validation
- Database Seeding
What is Laravel?
Laravel is a modern PHP framework that helps you build web applications quickly using the MVC architecture.
Example:
composer create-project laravel/laravel myApp
Example Description:
MVC Structure
MVC stands for Model-View-Controller — a design pattern that organizes code.
Example:
// routes/web.php
Route::get('/hello', 'HelloController@index');
Example Description:
Defining Routes
Routes define how your app responds to URLs.
Example:
Route::get('/about', function () {
return 'About Page';
});
Example Description:
Creating a Controller
Controllers handle business logic and connect models to views.
Example:
php artisan make:controller BlogController
Example Description:
Blade Templates
Blade is Laravel's templating engine used to generate dynamic views.
Example:
<!-- resources/views/welcome.blade.php --> <h1>Hello, {{ $name }}</h1>
Example Description:
Database Migrations
Migrations help define and modify database schema in code.
Example:
php artisan make:migration create_posts_table
Example Description:
Eloquent ORM
Eloquent allows you to interact with the database using models.
Example:
$post = Post::find(1); echo $post->title;
Example Description:
Authentication
Laravel provides built-in authentication scaffolding.
Example:
php artisan ui bootstrap --auth
Example Description:
Validation
Laravel simplifies input validation.
Example:
$request->validate([
'title' => 'required|min:3'
]);
Example Description:
Database Seeding
Seeders allow inserting sample data into your database for testing.
Example:
php artisan make:seeder PostSeeder
Example Description: