Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default controller in Yii

Tags:

php

yii

Is there a way to specify a default controller in Yii? Instead of using the SiteController? Thank you in advance.

like image 663
JohnnyQ Avatar asked Jul 07 '12 07:07

JohnnyQ


People also ask

What is controller in Yii?

Controllers are part of the MVC architecture. They are objects of classes extending from yii\base\Controller and are responsible for processing requests and generating responses.

What is module in Yii?

Modules are self-contained software units that consist of models, views, controllers, and other supporting components. End users can access the controllers of a module when it is installed in application. For these reasons, modules are often viewed as mini-applications.

What is composer in Yii?

Composer is a tool for dependency management in PHP. Yii2 uses it to install itself and other vendors' modules (for example, bootstrap). It is also possible to install Yii2 in the old way, by downloading the complete package and transferring it to the host, local or remote, where the framework will be installed.

Is Yii a MVC?

Yii implements the model-view-controller (MVC) design pattern, which is widely adopted in Web programming. MVC aims to separate business logic from user interface considerations, so that developers can more easily change each part without affecting the other.


2 Answers

To set your default controller as your homepage's controller on Yii PHP-Framework. You must modify the core defaults controller (site/index) on your /protected/config/main.php

return array(
    'name' => 'Web Application',
    'defaultController' => 'home ', 

);
like image 181
Moyed Ansari Avatar answered Sep 29 '22 19:09

Moyed Ansari


try to add the configuration in the config main.php

'defaultController' => 'newcontrollername',

after 'name' setting.

like image 28
bingjie2680 Avatar answered Sep 29 '22 17:09

bingjie2680