title: ZEND Framework 2 RESTful web service template error
body: <p>Hi I'm getting an error when I attempt to access a RESTful web service endpoint in my Zend Framework 2.2.2 project. I am creating a module named V1 and I am receiving the following error:</p>
  
  <p><code>Zend\View\Renderer\PhpRenderer::render: Unable to render template "v1/collateral/get-list"; resolver could not resolve to a file</code></p>
  
  <p>I assume that this indicates that the application cannot find a required view file. I started with <a href="http://hounddog.github.io/blog/getting-started-with-rest-and-zend-framework-2/" rel="nofollow">this tutorial</a>. I've searched for an answer to my issue and I've found some others with a similar issue but I haven't found the answer that I'm looking for at this point because I've still got an error. I'm relatively new to Zend Framework 2 so this may be an easy one for someone more experienced.</p>
  
  <p>Here is what I have done thus far regarding routing and the view manager strategy:</p>
  
  <p><strong>module.config.php:</strong></p>
  
  <pre><code>return array(
  'router' =&gt; array(
      'routes' =&gt; array(
          'collateral' =&gt; array(
              'type'    =&gt; 'segment',
              'options' =&gt; array(
                  'route'    =&gt; '/v1/collateral[/:id]',
                  'constraints' =&gt; array(
                      'id'     =&gt; '[0-9]+',
                  ),
                  'defaults' =&gt; array(
                      'controller' =&gt; 'V1\Controller\Collateral',
                  ),
              ),
          ),
      ),
  ),
  
  'controllers' =&gt; array(
      'invokables' =&gt; array(
          'V1\Controller\Collateral' =&gt; 'V1\Controller\CollateralController',
      ),
  ),
  
  'view_manager' =&gt; array(
      'strategies' =&gt; array(
              'ViewJsonStrategy',
      ),
  ),
  </code></pre>
  
  <p>);</p>
  
  <p>Here is my controller code</p>
  
  <p><strong>CollateralController.php</strong></p>
  
  <pre><code>namespace V1\Controller;
  
  use Zend\Mvc\Controller\AbstractRestfulController;
  
  use V1\Model\Collateral;
  //use V1\Form\CollateralForm;
  use V1\Model\CollateralTable;
  use Zend\View\Model\JsonModel;
  
  class CollateralController extends AbstractRestfulController
  {
  protected $collateralTable;
  
  public function getList()
  {
      $results = $this-&gt;getCollateralTable()-&gt;fetchAll();
      $data = array();
      foreach($results as $result) {
          $data[] = $result;
      }
  
      return array('data' =&gt; $data);
  }
  
  public function get($id)
  {
      # code...
  }
  
  /*public function create($data)
  {
      # code...
  }
  
  public function update($id, $data)
  {
      # code...
  }
  
  public function delete($id)
  {
      # code...
  }*/
  
  public function getCollateralTable()
  {
      if (!$this-&gt;collateralTable) {
          $sm = $this-&gt;getServiceLocator();
          $this-&gt;collateralTable = $sm-&gt;get('V1\Model\CollateralTable');
      }
      return $this-&gt;collateralTable;
  }
  }
  </code></pre>
  
  <p>And for good measure here is my <strong>Module.php</strong> file</p>
  
  <pre><code>            namespace V1;
  
              // Add these import statements:
              use V1\Model\Collateral;
              use V1\Model\CollateralTable;
              use Zend\Db\ResultSet\ResultSet;
              use Zend\Db\TableGateway\TableGateway;
  
              class Module
              {
  
                  public function getAutoloaderConfig()
                  {
                      return array(
                          'Zend\Loader\ClassMapAutoloader' =&gt; array(
                              __DIR__ . '/autoload_classmap.php',
                          ),
                          'Zend\Loader\StandardAutoloader' =&gt; array(
                              'namespaces' =&gt; array(
                                  __NAMESPACE__ =&gt; __DIR__ . '/src/' . __NAMESPACE__,
                              ),
                          ),
                      );
                  }
  
                  public function getConfig()
                  {
                      return include __DIR__ . '/config/module.config.php';
                  }
  
                  public function getServiceConfig()
                  {
                      return array(
                          'factories' =&gt; array(
                              'V1\Model\CollateralTable' =&gt;  function($sm) {
                                  $tableGateway = $sm-&gt;get('CollateralTableGateway');
                                  $table = new CollateralTable($tableGateway);
                                  return $table;
                              },
                              'CollateralTableGateway' =&gt; function ($sm) {
                                  $dbAdapter = $sm-&gt;get('Zend\Db\Adapter\Adapter');
                                  $resultSetPrototype = new ResultSet();
                                  $resultSetPrototype-&gt;setArrayObjectPrototype(new Collateral());
                                  return new TableGateway('collateral', $dbAdapter, null, $resultSetPrototype);
                              },
                          ),
                      );
                  }
              }
  </code></pre>
  
  <p>Although I'm not sure based on what I read in the tutorial if I need it or not I have created the following <em>empty</em> view file:</p>
  
  <p><code>\module\V1\view\v1\collateral\get-list.phtml</code></p>
  
  <p>I am wondering if this view file is required and is it in the correct location and named properly?</p>
  
  <p>Any other assistance with this error would be greatly appreciated. I'm happy to provide more info if it would be helpful.</p>
  
  <p>Thank you.</p>