How to use optional parameters in URI path in Yii framework

Posted by Stanislav Furman  on July 10, 2014

Yii - is one of my favorite frameworks. I've done a few projects using this framework and have been always satisfied with its functionality, flexibility, performance and community support. This post starts a series of "how to" articles where I will give some tips, advises and best practices.

If you need to use optional parameters in URLs here is how you can do it in UrlManager:


<?php
$routing = array(
    'view/<user_id:[\d+]>(/<action:.*?>)?'=>'user/view'
);
?>

If you have questions about Yii framework, do not hesitate to contact me using the contact form.


Leave your comment

Fields with * are required.

* When you submit a comment, you agree with Terms and Conditions of Use.