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";
});
PHPRoute Methods (सभी types)
Laravel में कई HTTP methods होते हैं:
| Method | Work |
|---|---|
| GET | डेटा लाना |
| POST | डेटा भेजना |
| PUT | डेटा अपडेट करना |
| PATCH | आंशिक अपडेट |
| DELETE | डेटा हटाना |
| ANY | कोई भी method |
| MATCH | specific methods allow करना |
Basic Route Example
Route::get('/', function () {
return view('welcome');
});PHPRoute with Parameters
Single Parameter:
Route::get('/post/{year}/{slug}', function ($year, $slug) {
return "Post: $slug ($year)";
});
PHPMultiple Parameter:
Route::get('/post/{year}/{slug}', function ($year, $slug) {
return "Post: $slug ($year)";
});PHPOptional Parameters
Route::get('/product/{name?}', function ($name = "Default Product") {
return $name;
});PHPRoute Constraints (Validation on URL)
Route::get('/user/{id}', function ($id) {
return $id;
})->where('id', '[0-9]+');PHPNamed Routes
Named route URL बदलने पर भी code break नहीं होने देता।
Route::get('/profile', function () {
return "My Profile";
})->name('profile');PHPUse:
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 () {});
});PHPGenerated URLs:
/admin/login
/admin/dashboardPHP🔐 Route Middleware
Authentication, security और filters के लिए:
Route::middleware(['auth'])->group(function () {
Route::get('/dashboard', function () {});
});PHP🔥 Resource Routing (CRUD का Shortcut!)
Route::resource('products', ProductController::class);PHPAutomatically creates:
| Method | URL | Action |
|---|---|---|
| GET | /products | index |
| GET | /products/create | create |
| POST | /products | store |
| GET | /products/{id} | show |
| GET | /products/{id}/edit | edit |
| 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:clearBash🧠 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

Welcome to HindiTutorials, your go-to platform for learning and mastering concepts in Hindi! Our mission is to make education accessible and simple for everyone by providing high-quality tutorials on programming, technology, and various other topics.