Rajat Modi
Rajat Modi

Reputation: 1343

got the error of renderer fatal error in zf2

got 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "users/users/index" while I am calling my users module here is the code of module.config.php

<?php
 return array(
'controllers' => array(
    'invokables' => array(
        'Users\Controller\Users' => 'Users\Controller\UsersController',
    ),

),

'router' => array(
    'routes' => array(
        'users' => array(
            'type'    => 'segment',
            'options' => array(
                'route'    => '/users[/:action][/:id]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id'     => '[0-9]+',
                ),
                'defaults' => array(
                    'controller' => 'Users\Controller\Users',
                    'action'     => 'index',
                ),
            ),
        ),
    ),
),

'view_manager' => array(
    'template_path_stack' => array(
        'users' => __DIR__ . '/../view',
    ),
),
);

when I call localhost/myprj/public/users

it is going on my userscontroller.php in indexAction here is the code of controller.

public function indexAction()
{ 
    return new ViewModel(array(
            'users' => $this->getUsersTable()->fetchAll(),
        ));
}

I got the above fatal error I also created index.phtml underneath module/Users/view/users/users

And here is my index.phtml code

 <?php 
     echo "here I am!!";
  ?>

any help will be awesome.

Upvotes: 0

Views: 199

Answers (1)

Andrew
Andrew

Reputation: 12809

Try changing your module config to this (remove the 'users' key):

...
'view_manager' => array(
    'template_path_stack' => array(
        __DIR__ . '/../view',
    ),
),

Upvotes: 1

Related Questions