Laravel Routing
Laravel Routing
Route that responds to multiple HTTP verbs
You may do so using the match method. Or, you may even register a route that responds to all HTTP verbs using the any method.
Route Parameters
Are always encased within {} braces and should consist of alphabetic characters, and may not contain a - character. Instead of using the - character, use an underscore (_).
Are injected into route callbacks / controllers based on their order - the names of the callback / controller arguments do not matter.
Route Groups
Allow you to share route attributes, such as middleware or namespaces, across a large number of routes without needing to define those attributes on each individual route.
Another common use-case for route groups is assigning the same PHP namespace to a group of controllers using the namespace method.
Route Model Binding
Accessing The Current Route
Basic Routing
Fallback Routes
Using the Route::fallback method, you may define a route that will be executed when no other route matches the incoming request.
Since you may define the fallback route within your routes/web.php file, all middleware in the web midddleware group will apply to the route.
- Routes/web.php.
Syntax
Route::fallback(function () {
//
});
Rate Limiting
Route::middleware('auth:api', 'throttle:rate_limit,1')->group(function () {
Route::get('/user', function () {
//
});
});
Laravel includes a middleware to rate limit access to routes within your application.
Form Method Spoofing
Related concepts
- Laravel Service Providers
- Route Files
- Route Files: routes/web.php
- Route Files: routes/api.php
- Laravel Routing: Route that responds to multiple HTTP verbs
- Laravel Routing: Route Parameters
- Route Parameters: Required Parameters
- Route Parameters: Optional Parameters
- Named Routes: Inspecting The Current Route
- Laravel Routing: Route Groups
- Route Groups: Sub-Domain Routing
- Route Groups: Route Prefixes
- Route Groups: Route Name Prefixes
- Laravel Routing: Route Model Binding
- Route Model Binding: Implicit Binding
- Route Model Binding: Explicit Binding
- Explicit Binding: Customizing The Resolution Logic
- Laravel Routing: Fallback Routes
- Laravel Routing: Accessing The Current Route
- Global Middleware: Assigning Middleware To Routes
- Registering Middleware: Middleware Groups
- Laravel Middleware: Middleware Parameters
- Laravel Middleware: Terminable Middleware
- CSRF Protection: Excluding URIs From CSRF Protection
- Basic Controllers: Controllers & Namespaces
- Laravel Controllers: Controller Middleware
- Laravel Controllers: Resource Controllers
- Resource Controllers: Specifying The Resource Model
- Resource Controllers: Partial Resource Routes
- Resource Controllers: Naming Resource Route Parameters
- Resource Controllers: Localizing Resource URIs
- Resource Controllers: Supplementing Resource Controllers
- Laravel Controllers: Route Caching
- Accessing The Request: Dependency Injection & Route Parameters
- Accessing The Request: Accessing The Request Via Route Closures
- Accessing The Request: PSR-7 Requests
- Laravel Routing: Basic Routing
- Basic Routing: The Default Route Files
- Basic Routing: Available Router Methods
- Redirects: Redirecting To Named Routes
- Redirecting To Named Routes: Populating Parameters Via Eloquent Models
- Laravel URL Generation: URLs For Named Routes
- Signed URLs: Validating Signed Route Requests
- Authentication Quickstart: Routing
- Laravel Email Verification: Routing
- Laravel Password Reset: Routing
- Laravel Routing: Rate Limiting
- Laravel Routing: Form Method Spoofing