Create View in Zendframework
Last Updated: January 26, 2018
Lets see how we can create a view in zendframework. You can load the view by returning the new ViewModel()
inside the action of a controller
You have the ProductController with following code
namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class ProductController extends AbstractActionController { public function indexAction() { return new ViewModel(); } }
How does ZF know which file to be loaded?
ZF looks for view\application\product\index.phtml
So you can create that index.phtml file in that location
This is product index view
If you have add route and the controller to this file module\Application\config\module.config.php
the you are done. If you do not know how to make route you can refer this article, also you can look for how to create controller article
You can see the following screen on http://localhost:8000/product