Home  >  Article  >  Backend Development  >  Detailed explanation of the steps of configuring controller and action in Yii framework

Detailed explanation of the steps of configuring controller and action in Yii framework

php中世界最好的语言
php中世界最好的语言Original
2018-05-21 09:52:302436browse

This time I will bring you the yii frameworkdetailed explanation of the steps to configure the controller and action. What are the precautions for configuring the controller and action in the yii framework? The following are Let’s take a look at practical cases.

In the yii framework, set the default controller

Add configuration in /protected/config/main.php

<?php
return
 array(
 &#39;name&#39;=>&#39;Auto&#39;,
&#39;defaultController&#39;=>&#39;auto&#39;,

The default controller configured above is AutoController.php

In the yii framework, set the default action
Set in AutoController.php

class
 AutoController 
extends
 CController
{
    public $defaultAction = &#39;test&#39;;
    public function actionTest()
    {
    }

When you access xxxx/index.php at this time, will it go to xxxx/index.php by default? r=auto/test means the setting is successful.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

PHP7 uses lib library case code analysis based on function method

PHP finds the entry node in the linked list Detailed explanation of steps

The above is the detailed content of Detailed explanation of the steps of configuring controller and action in Yii framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn