The framework uses an opinionated directory structure that is very similar to other MVC or MVVM applications. For the ExampleController found inside the application/controllers directory, there is a model inside the application/models/Example/ directory called ExampleModel.class.php, which is automatically bound to any action within the controller.
Below the ExampleController has been shortened for the purposes of this example.
<?php
class ExampleController extends FrontController
{
/**
* URL: Example/helloWorld/
*
* @return View
*/
public function helloWorldAction()
{
$this->view->title = "Hello World";
$this->view->whoAmI = $this->model->whatIsMyName();
$this->view->renderer("Example", "hello");
return $this->view();
}
} /*end of class ExampleController*/Below is the application/models/Example/ExampleModel.class.php which is automatically bound to the $this->model variable which can be used by any action inside the ExampleController; which in this example happens to be the helloWorldAction().
<?php
class ExampleModel
{
/**
* Returns a simple string message
*
* @return string
*/
public function whatIsMyName()
{
return "ExampleModel";
}
/**
* Returns a class statement if parameters match
*
* @param int $menuIndex menuIndex of currently set
* @param int $index index of menu
* @return string
*/
public function isMenuActive($menuIndex, $index)
{
if ($menuIndex == $index)
{
return "active";
}
return "";
}
} /*end of class ExampleModel*/Default model binding is completely optional. But when a model is used, the convention is to save it in the application/models/ControllerName directory with a file matching ControllerNameModel.class.php, and in this example ControllerName is Example.