Answer the question
In order to leave comments, you need to log in
How to make zend framework 2.0 follow links?
here is my controller code
<?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');
return $view;
}
public function loginAction(){
$view = new ViewModel();
$view->setTemplate('users/index/login');
return $view;
}
}
Answer the question
In order to leave comments, you need to log in
The answer was found, you need to edit config/module.config.php
for walking on the links, the view should be like that.
<?php
return array(
'view_manager' => array(
'template_path_stack' => array(
__DIR__.'/../view'
)
),
'router'=> array(
'routes'=>array(
'users'=>array(
'type' =>'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route'=>'/users',
'defaults'=> array(
'__NAMESPACE__'=> 'Users\Controller',
'controller'=>'Index',
'action'=>'index',
)
),
'may_terminate' => true,
'child_routes' => array(
// This route is a sane default when developing a module;
// as you solidify the routes for your module, however,
// you may want to remove it and replace it with more
// specific routes.
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
)
)
),
'controllers'=>array(
'invokables'=>array(
'Users\Controller\Index'=> 'Users\Controller\IndexController'
)
),
)
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question