Laravel Routing in Hindi – Complete Beginner to Advanced Guide 2026

Laravel की सबसे ताकतवर और मज़ेदार फीचर्स में से एक है—Laravel Routing।
इसी के जरिए user आपका application access करता है, pages load होते हैं और पूरा web flow काम करता है।
Beginner हों या प्रो, Routing को master किए बिना Laravel में आगे बढ़ना मुश्किल है।

Laravel Routing क्या है?

Routing Laravel का वह system है जो यह तय करता है:

  • User ने कौन-सा URL request किया?
  • उस URL पर कौन सा function या controller चलेगा?
  • कौन-सा data return होगा?

👉 सरल शब्दों में:
Route = Way (रास्ता) जो User को सही Page या Function तक पहुँचाता है।

Laravel में सभी routes /routes/web.php और /routes/api.php में define होते हैं।

Routing क्यों जरूरी है?

  • Application flow control के लिए
  • Clean URL structure के लिए
  • SEO-friendly URLs बनाने के लिए
  • Security और Middleware control के लिए
  • API endpoints define करने के लिए

Laravel Routing का Basic Syntax

Route::get('/home', function () {
    return "Welcome to Home Page";
});
PHP

Route Methods (सभी types)

Laravel में कई HTTP methods होते हैं:

MethodWork
GETडेटा लाना
POSTडेटा भेजना
PUTडेटा अपडेट करना
PATCHआंशिक अपडेट
DELETEडेटा हटाना
ANYकोई भी method
MATCHspecific methods allow करना

Basic Route Example

Route::get('/', function () {
    return view('welcome');
});
PHP

Route with Parameters

Single Parameter:

Route::get('/post/{year}/{slug}', function ($year, $slug) {
    return "Post: $slug ($year)";
});
PHP

Multiple Parameter:

Route::get('/post/{year}/{slug}', function ($year, $slug) {
    return "Post: $slug ($year)";
});
PHP

Optional Parameters

Route::get('/product/{name?}', function ($name = "Default Product") {
    return $name;
});
PHP

Route Constraints (Validation on URL)

Route::get('/user/{id}', function ($id) {
    return $id;
})->where('id', '[0-9]+');
PHP

Named Routes

Named route URL बदलने पर भी code break नहीं होने देता।

Route::get('/profile', function () {
    return "My Profile";
})->name('profile');
PHP

Use:

return redirect()->route('profile');
PHP

🛠 Controller Routes

Instead of writing function inside route:

Route::get('/home', [HomeController::class, 'index']);
PHP

🗂 Route Grouping

Route::prefix('admin')->group(function () {
    Route::get('/login', function () {});
    Route::get('/dashboard', function () {});
});
PHP

Generated URLs:

/admin/login  
/admin/dashboard
PHP

🔐 Route Middleware

Authentication, security और filters के लिए:

Route::middleware(['auth'])->group(function () {
    Route::get('/dashboard', function () {});
});
PHP

🔥 Resource Routing (CRUD का Shortcut!)

Route::resource('products', ProductController::class);
PHP

Automatically creates:

MethodURLAction
GET/productsindex
GET/products/createcreate
POST/productsstore
GET/products/{id}show
GET/products/{id}/editedit
PUT/products/{id}update
DELETE/products/{id}destroy

🌐 API Routing (api.php)

API routes:

  • Stateless होते हैं
  • Token आधारित authorization इस्तेमाल करते हैं

Example:

Route::get('/users', function () {
    return User::all();
});
PHP

🚀 Route Caching – Application Speed Boost

php artisan route:cache
php artisan route:clear
Bash

🧠 Best Practices (Professional Tips)

✔ URLs lowercase रखें
✔ Action-based naming करें
✔ Route groups का उपयोग करें
✔ Duplicate logic routes में न रखें
✔ API routes + versioning use करें
✔ Prefixes का उपयोग करें (admin/user/app)

🏁 Conclusion – Routing क्यों Laravel का दिल है?

Laravel Routing:

  • Clean URLs देता है
  • SEO improve करता है
  • Application flow manage करता है
  • APIs बनाना आसान बनाता है
  • Middleware के जरिए security provide करता है

Laravel Routing को master करके आप web development में expert-level control पा सकते हैं।

Free Shopping Online On Best Amazon Affiliate Store

error: Content is protected!! You are not allowed to copy.