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

php中世界最好的语言
Release: 2023-03-27 06:42:02
Original
2352 people have browsed it

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;,
Copy after login

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()
    {
    }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!