Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How can I debug the rendering of a view?

I have a multiple module application that is working absolutely fine. I have come across an issue that I am having trouble resolving. There is one url that wont render the relevant view.

I have the router configured like so:

$router->add("/user", array(
    'module'     => 'backend',
    'controller' => 'user',
    'action'     => 'index'

Inside the "UserController" I have an "indexAction" which is being called perfectly. I have the view file inside "apps/backend/views/user/index.phtml"

This file is not being rendered. I cannot understand why as the following route has exactly the same file structure to the view, and renders perfectly.

    '/admin/:controller', array(
    'module'     => 'backend',
    'controller' => 1,
    'action'     => 'index',        

I understand that this could be very difficult for someone to help with without seeing the full code. If that is the case I would be very grateful if someone could tell me how I can debug this. I have Phalcon debuging enabled but it returns nothing as if everything is ok. For example is there a way to find out where Phalcon is looking for the view file?

Thanks in advance.

edited Nov '14

You can attach a listener to your view service

$eventsManager = new Phalcon\Events\Manager();
$eventsManager->attach("view", function($event, $view) {
      if ($event->getType() == 'notFoundView') {      
        throw new Exception('View not found' . $view->getActiveRenderPath());

This should show you what view file it tries to render, hopefully this will be helpfull for you


Thanks mirago, works perfect!