Now that we have created the module, our next step would be having our own controllers and views defined. In this section, we will create two simple views and will write a controller to switch between them:
Navigate to the module location:
$ cd /var/www/CommunicationApp/module/Users
Create the folder for controllers:
$ mkdir -p src/Users/Controller/
Create a new
IndexController
file,< ModuleName >/src/<ModuleName>/Controller/
:$ cd src/Users/Controller/ $ vim IndexController.php
Add the following code to the
IndexController
file:<?php namespace Users\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class IndexController extends AbstractActionController { public function indexAction() { $view = new ViewModel(); return $view; } public function registerAction() { $view = new ViewModel(); $view->setTemplate('users/index/new-user')...