دليل استخدام Laravel

Laravel# Laravel Beginner Guide: Installation, Ecosystem & Request Lifecycle
Laravel is one of the most popular PHP frameworks for building modern web applications. It is designed to make development faster, cleaner, and more structured by providing a powerful ecosystem and expressive syntax.
In this guide, we will cover:
-
How to install Laravel
-
Laravel ecosystem overview
-
How Laravel works internally (Request Lifecycle)
-
Basic Eloquent ORM examples
1. Installing Laravel
Requirements
Before installing Laravel, make sure you have:
-
PHP >= 8.1
-
Composer
-
MySQL or any database (PostgreSQL, SQLite also works)
-
Node.js (recommended for frontend tooling)
Install Laravel
Create a new Laravel project:
composer create-project laravel/laravel my-app
Go inside the project:
cd my-app
Start local development server:
php artisan serve
Now open:
http://127.0.0.1:8000
2. Laravel Ecosystem Overview
Laravel is not just a framework — it is a complete ecosystem for building modern applications.
Core Components
🔹 Laravel Framework
The main backend framework built with PHP following MVC architecture.
🔹 Artisan CLI
A powerful command-line tool for automation:
php artisan make:controller UserController
php artisan migrate
php artisan make:model Post -m
🔹 Eloquent ORM
Laravel’s built-in ORM for database interaction using models instead of raw SQL.
🔹 Blade Templating Engine
Used to build dynamic frontend views inside Laravel.
🔹 Authentication Systems
-
Laravel Breeze (simple auth)
-
Laravel Jetstream (advanced auth system)
🔹 API Authentication
-
Laravel Sanctum (lightweight API auth)
-
Laravel Passport (OAuth2 full solution)
🔹 Queue System
Used to handle background tasks like:
-
Sending emails
-
Processing jobs
-
Notifications
🔹 Task Scheduling
Laravel allows cron jobs inside the framework:
php artisan schedule:run
3. Laravel Request Lifecycle
Understanding the request lifecycle is very important.
When a user sends a request, Laravel processes it like this:
1. Entry Point
All requests start from:
public/index.php
This file bootstraps the framework.
2. HTTP Kernel
The request is handled by:
App\Http\Kernel
It loads:
-
Middleware
-
Service providers
-
Application bootstrap
3. Middleware Layer
Middleware acts as a filter before request reaches your application.
Examples:
-
Authentication check
-
CSRF protection
-
Logging requests
-
Rate limiting
4. Routing System
Routes are defined in:
routes/web.php
routes/api.php
Example:
Route::get('/users', [UserController::class, 'index']);
5. Controller Layer
Controllers handle the business logic:
class UserController extends Controller
{
public function index()
{
return User::all();
}
}
6. Model Layer (Eloquent ORM)
Models interact with the database using Eloquent ORM.
7. Response
Laravel sends response back to the client:
-
JSON (API)
-
HTML (Blade views)
4. Eloquent ORM Examples
Eloquent makes database interaction simple and clean.
Create Model + Migration
php artisan make:model Post -m
Migration Example
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('content');
$table->timestamps();
});
Run migration:
php artisan migrate
Insert Data
Post::create([
'title' => 'Hello Laravel',
'content' => 'This is my first post'
]);
Get All Records
$posts = Post::all();
Get Single Record
$post = Post::find(1);
Update Record
$post = Post::find(1);
$post->title = "Updated Title";
$post->save();
Delete Record
Post::destroy(1);
5. Why Laravel is Powerful
Laravel is widely used because it provides:
-
Fast development speed
-
Clean MVC architecture
-
Strong ecosystem
-
Built-in security features
-
Powerful ORM (Eloquent)
-
Large community support
-
Easy API development
Final Thoughts
Laravel is not just a backend framework — it is a complete ecosystem that helps developers build scalable, maintainable, and modern applications efficiently.
If you understand the request lifecycle and Eloquent ORM, you already have a strong foundation in backend development.