Controller is a main entry of a page, after routing.
Here's a basic example of controller that extends the base controller that's included in the framework.
namespace namespace Application\Controller;
use JiNexus\Mvc\Controller\AbstractController;
use JiNexus\Mvc\Model\ViewModel;
/**
* Class IndexController
* @package Application\Controller
*/
class IndexController extends AbstractController
{
/**
* @return ViewModel
*/
public function indexAction()
{
// Pass a variable to the view
return new ViewModel([
'foobar' => 'Hello World!'
]);
}
}
Method names should have a suffix of a word "Action" to match it and dispatch.
If you found a typo or error, please help us improve this document. Contact Us