vlr
vlr

Reputation: 790

Unable to render - resolver could not resolve to a file

I am trying to setup module structure for my Zend project, and this is an error I am getting. I do not understand why Renderer looking for this path "online-field-evaluation/online-field-evaluation/index" . Is there some problem with Camel notation in Zend ? Thanks.

Zend\View\Exception\RuntimeException

File:

    C:\dev\xampp\htdocs\OnlineFieldEvaluation\vendor\zendframework\zendframework\library\Zend\View\Renderer\PhpRenderer.php:499

Message:

    Zend\View\Renderer\PhpRenderer::render: Unable to render template "online-field-evaluation/online-field-evaluation/index"; resolver could not resolve to a file

Stack trace:

    #0 C:\dev\xampp\htdocs\OnlineFieldEvaluation\vendor\zendframework\zendframework\library\Zend\View\View.php(205): Zend\View\Renderer\PhpRenderer->render(Object(Zend\View\Model\ViewModel))
    #1 C:\dev\xampp\htdocs\OnlineFieldEvaluation\vendor\zendframework\zendframework\library\Zend\View\View.php(233): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
    #2 C:\dev\xampp\htdocs\OnlineFieldEvaluation\vendor\zendframework\zendframework\library\Zend\View\View.php(198): Zend\View\View->renderChildren(Object(Zend\View\Model\ViewModel))
    #3 C:\dev\xampp\htdocs\OnlineFieldEvaluation\vendor\zendframework\zendframework\library\Zend\Mvc\View\Http\DefaultRenderingStrategy.php(102): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
    #4 [internal function]: Zend\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Zend\Mvc\MvcEvent))
    #5 C:\dev\xampp\htdocs\OnlineFieldEvaluation\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(471): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
    #6 C:\dev\xampp\htdocs\OnlineFieldEvaluation\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('render', Object(Zend\Mvc\MvcEvent), Array)
    #7 C:\dev\xampp\htdocs\OnlineFieldEvaluation\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(347): Zend\EventManager\EventManager->trigger('render', Object(Zend\Mvc\MvcEvent))
    #8 C:\dev\xampp\htdocs\OnlineFieldEvaluation\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(322): Zend\Mvc\Application->completeRequest(Object(Zend\Mvc\MvcEvent))
    #9 C:\dev\xampp\htdocs\OnlineFieldEvaluation\public\index.php(25): Zend\Mvc\Application->run()
    #10 {main}

Here is my module.config.php:

<?php
return array(
    'controllers' => array(
        'invokables' => array(
            'OnlineFieldEvaluation\Controller\OnlineFieldEvaluation' => 'OnlineFieldEvaluation\Controller\OnlineFieldEvaluationController',
        ),
    ),

    // The following section is new and should be added to your file
    'router' => array(
            'routes' => array(
                    'onlinefieldevaluation' => array(
                            'type'    => 'segment',
                            'options' => array(
                                    'route'    => '/onlinefieldevaluation[/][:action][/:id]',
                                    'constraints' => array(
                                            'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                            'id'     => '[0-9]+',
                                    ),
                                    'defaults' => array(
                                            'controller' => 'onlinefieldevaluation\Controller\onlinefieldevaluation',
                                            'action'     => 'index',
                                    ),
                            ),
                    ),
            ),
    ),      
    'view_manager' => array(
        'template_path_stack' => array(
            'onlinefieldevaluation' => __DIR__ . '/../view',
        ),
    ),
);

And here is my Module.php

<?php

namespace OnlineFieldEvaluation;

class Module
{
    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\ClassMapAutoloader' => array(
                __DIR__ . '/autoload_classmap.php',
            ),
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }
}

**EDIT 1: here is the image of my project structure : **

enter image description here

Upvotes: 1

Views: 4976

Answers (1)

Remi Thomas
Remi Thomas

Reputation: 1528

on your config.php you wrote

    'invokables' => array(
        'OnlineFieldEvaluation\Controller\OnlineFieldEvaluation' => 'OnlineFieldEvaluation\Controller\OnlineFieldEvaluationController',
    ),

But you call

'defaults' => array(
       'controller' => 'onlinefieldevaluation\Controller\onlinefieldevaluation',
       'action'     => 'index',
),

change by this

'defaults' => array(
       'controller' => 'OnlineFieldEvaluation\Controller\OnlineFieldEvaluation',
       'action'     => 'index',
),

and change the folders names of your view script to lowercase like

view
  online-field-evaluation
     online-field-evaluation

Upvotes: 5

Related Questions