-
Notifications
You must be signed in to change notification settings - Fork 10
Route Params & Regex
Devin Smith edited this page Jan 21, 2016
·
2 revisions
Routes accept params similar to Express Routes.
$tipsy->router()->when('user/:name', function($Params) {
echo $Params->name;
});
Route Aliases map params based on the Param Name
$tipsy->router()->alias('group/:project/user/:name', 'user/:name');
Routes can also accept a full regex. When a regex is used, params is an array of matches.
$tipsy->router()->when('/^api\/user\/(.*)\/details$/i', function($Params) {
echo $Params[1]; // the user name of the service
});
Regex is especially useful when catching files that need to render.
$tipsy->router()->when('/\.scss$/i', function($Request) {
echo $Request->path(); // the requested file
});
- Home
- Getting Started
- Server Config
- Installation
- Installing Composer
- App
- Route Shorthand
- Config
- Routes
- Methods
- Controller Types
- Params & Regex
- Aliases
- Dependency Injection
- Advanced Routing
- Services
- User Defined Services
- Built in Services
- Middleware
- Views
- Templates
- Scope
- Resource
- Factory
- Looper
- Examples
- Plugins
- About