Skip to main content

Introduction

Lyger’s routing system provides a clean and expressive way to define your application’s routes. All routes are defined in the routes/web.php file and support common HTTP methods through the Route facade.

Available HTTP Methods

The router supports all standard HTTP methods:

Route Handlers

Routes can use either closures or controller methods as handlers.

Closure Handlers

The simplest way to define a route is with a closure function:
All route handlers receive the Request object as the first parameter automatically.

Controller Handlers

For better organization, you can reference controller methods using an array syntax:
The controller method will automatically receive the Request object:

Response Types

Lyger provides convenient methods for returning different response types:

Auto-Response Formatting

If you return a non-Response value, the router will automatically format it:

Status Codes and Headers

You can customize response status codes and headers:

Loading Routes

Routes are automatically loaded from the routes/web.php file when the application bootstraps:
If no route matches the incoming request, the router will automatically return a 404 Not Found response.

Working with the Request Object

Every route handler receives the Request object as the first parameter:

Next Steps

Route Parameters

Learn how to capture dynamic segments in your URLs

Middleware

Add middleware to filter and process requests