Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9175985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:00:32+00:00 2026-06-17T17:00:32+00:00

In the basic sample application that is used with ZF2, the IndexController is coded

  • 0

In the basic sample application that is used with ZF2, the IndexController is coded as follows:

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        return new ViewModel();
    }
}

There’s just a simple return statement and the contents of index.phtml are automatically included in the output.

The only place I’ve seen the index.phtml referenced is in \module\Application\config\module.config.php

'view_manager' => array(
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => array(
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
    ),

I’ve tried commenting this line out:

//'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',

But the index.phtml is still included in the output.

So the question is, why is it included? What magic is happening behind the scenes to cause it to still be included?

It seems to me like maybe I’m missing some fundamental automatic mapping handled by ZF2 that I haven’t been able to find in documentation. But if there’s some automatic mapping, why does that line exist in the module.config.php?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:00:32+00:00Added an answer on June 17, 2026 at 5:00 pm

    So it turns out there’s a redundancy in the module.config.php

    'view_manager' => array(
            'display_not_found_reason' => true,
            'display_exceptions'       => true,
            'doctype'                  => 'HTML5',
            'not_found_template'       => 'error/404',
            'exception_template'       => 'error/index',
            'template_map' => array(
                'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
                'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
                'error/404'               => __DIR__ . '/../view/error/404.phtml',
                'error/index'             => __DIR__ . '/../view/error/index.phtml',
            ),
            'template_path_stack' => array(
                __DIR__ . '/../view',
            ),
        ),
    

    This line is a static mapping:

    'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
    

    These lines are a dynamic mapping:

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

    The Usage Section on this page made it clear to me.
    http://framework.zend.com/manual/2.0/en/modules/zend.view.quick-start.html

    It uses the Static mapping when it can for performance, and then fails over to the dynamic mapping. Commenting out both actually causes an error, ViewModel() can’t find the page to include.

    Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "application/index/index"; resolver could not resolve to a file'

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an application that can be used to create pictures that
I have a simple standalone application written in Visual Basic that I'm porting to
We have a function used within our PHP/MySQL application which returns basic configuration information,
We have a very basic application (iOS/Android) done in Appcelerator that will receive a
I'm trying to achieve a very basic goal that used to be quite simple
I want to implement some basic tracing in a simple c# (WPF) application that
I noticed a strange thing about OpenCV. I used one of the basic sample
I'm working in the skeleton basics sample WPF application C# found in the kinect
We have created a simple wix project for a basic windows application. Everything builds
Can someone provide basic sample / link for MVP Framework. Need to design a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.