Skip to content

Controllers and Actions

Yuriy edited this page Jan 30, 2016 · 4 revisions

CMF Lucent based on MVC architectural pattern (for more information wikipedia). A controller can send commands to the model to update the model's state. It can also send commands to its associated view to change the view's presentation of the model.

Create a controller is quite simple task. First of all you have to figured out what name of class it has to be. Simple pattern: nameController, where name is your own name of controller and “Controller” is just suffix. All controllers have to be named as CamelCase - practice of writing compound words or phrases such that each word or abbreviation begins with a capital letter. But first word has to be lower case.

Examples: mainController, generalController, manageController

Each controller class has to extend SysController

Example:

namespace app\controllers;

use core\classes\SysController;

class testController extends SysController {}

The controller defines action methods. Controllers can include as many action methods as needed. Example:

public function actionMain() { echo 'Hello World'; }

Now you can see the result: http://example.com/test/main

Clone this wiki locally