Commit 0126e7b0 authored by Igor Wiedler's avatar Igor Wiedler

[docs] document route default values

parent 755ee2f8
...@@ -230,6 +230,9 @@ While it's not suggested, you could also do this (note the switched arguments):: ...@@ -230,6 +230,9 @@ While it's not suggested, you could also do this (note the switched arguments)::
... ...
}); });
Requirements
~~~~~~~~~~~~
In some cases you may want to only match certain expressions. You can define In some cases you may want to only match certain expressions. You can define
requirements using regular expressions by calling ``assert`` on the requirements using regular expressions by calling ``assert`` on the
``Controller`` object, which is returned by the routing methods. ``Controller`` object, which is returned by the routing methods.
...@@ -250,6 +253,22 @@ You can also chain these calls:: ...@@ -250,6 +253,22 @@ You can also chain these calls::
->assert('postId', '\d+') ->assert('postId', '\d+')
->assert('commentId', '\d+'); ->assert('commentId', '\d+');
Default values
~~~~~~~~~~~~~~
You can define a default value for any route variable by calling ``value`` on
the ``Controller`` object.
::
$app->get('/{pageName}', function($pageName) {
...
})
->value('pageName', 'index');
This will allow matching ``/``, in which case the ``pageName`` variable will
have the value ``index``.
Named routes Named routes
~~~~~~~~~~~~ ~~~~~~~~~~~~
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment