Home >Backend Development >PHP Tutorial >Yii configure default controller and action_PHP tutorial
Set default controller
Add configuration in
/protected/config/main.php<span 1</span> <?<span php </span><span 2</span> <span return</span> <span array</span><span ( </span><span 3</span> 'name'=>'Auto', <span 4</span> 'defaultController'=>'auto', <span 5</span> ...
The default controller configured above is AutoController.php
Set default action
Set in AutoController.php
<span class</span> AutoController <span extends</span><span CController { </span><span public</span> <span $defaultAction</span> = 'test'<span ; </span><span public</span> <span function</span><span actionTest() { </span>...<span } </span>...
At this time, accessing xxxx/index.php will by default go to xxxx/index.php?r=auto/test