Now's the time to create a new controller. To do that, you will have to perform the following steps:
Create a new class inside
<project root>/module/Application/src/Application/Controller
.Name it
CookingController
, and set the namespaceApplication\Controller
.Use the namespace for the model since you need the model's methods in your code.
Use the namespace for
AbstractActionController
as you need to tell Zend that your controller isAbstractActionController
.Use the namespace for
ViewModel
since you will need to render a view when you run the code. Your controller will look like the following code:namespace Application\Controller; use Application\Model\Cooking; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class CookingController extends AbstractActionController { public function indexAction() { $dishname = 'Pizza'; $items = new Cooking(); $renderView = new ViewModel( array('dishname...