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

  • SEARCH
  • Home
  • 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 8910495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:42:13+00:00 2026-06-15T03:42:13+00:00

I am looking for some help with the ZF2 router configuration. I would like

  • 0

I am looking for some help with the ZF2 router configuration.

I would like to add multiple controllers to a single module in a development context, although will eventually have to figure out how to specify specific routes.

To do this I am currently trying to use the general purpose module.config specified in the MVC quick start documentation. However this does not seem to perform as the ZF2 documentation would suggest.

http://framework.zend.com/manual/2.0/en/modules/zend.mvc.quick-start.html

The documentation notes:

“ZendSkeletonApplication ships with a “default route” that will likely
get you to this action. That route basically expects
“/{module}/{controller}/{action}”, which allows you to specify this:
“/zend-user/hello/world”. We’re going to create a route here mainly
for illustration purposes, as creating explicit routes is a
recommended practice.”

However, the controller renders /landlord,
/landlord/home/index, but not /landlord/sandbox/index. Home and sandbox are controllers. Sandbox has been named in line with the naming convention “SandboxController”. My take is that perhaps the child_routes section of the code in the documentation needs some sort of modification that I have missed.

In the sandbox instance I get this error on the 404 error page.

Landlord\Controller\Sandbox(resolves to invalid controller class or
alias: Landlord\Controller\Sandbox)

I tried adding ‘Landlord\Controller\Sandbox’ => ‘Landlord\Controller\SandboxController’, to the invokables, but this creates an error.

My controller is listed below:

return array(
'controllers' => array(
    'invokables' => array(
        'Landlord\Controller\Home' => 'Landlord\Controller\HomeController',

    ),
),
'router' => array(
    'routes' => array(
        'landlord' => array(
            'type'    => 'Literal',
            'options' => array(
                // Change this to something specific to your module
                'route'    => '/landlord',
                'defaults' => array(
                    // Change this value to reflect the namespace in which
                    // the controllers for your module are found
                    '__NAMESPACE__' => 'Landlord\Controller',
                    'controller'    => 'home',
                    'action'        => 'index',
                ),
            ),
            'may_terminate' => true,
            'child_routes' => array(
                // This route is a sane default when developing a module;
                // as you solidify the routes for your module, however,
                // you may want to remove it and replace it with more
                // specific routes.
                'default' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route'    => '/[:controller[/:action]]',
                        'constraints' => array(
                            'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                            'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                        ),
                        'defaults' => array(
                        ),
                    ),
                ),
            ),
        ),
    ),
),
'view_manager' => array(
    'template_path_stack' => array(
        'landlord' => __DIR__ . '/../view',
    ),
),
);

If there is a simple way to directly configure urls, this would also be useful, or a really good tutorial this would also be appreciated.

  • 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-15T03:42:15+00:00Added an answer on June 15, 2026 at 3:42 am

    The problem here is that even though the router would try to route to your new controller that you added you still need to add the Invokable part for every single controller that you add. So your router appears to be fine at this point but if you add for instance a new AboutController then you will need to modify the top of your config like so…

    return array(
    'controllers' => array(
        'invokables' => array(
            'Landlord\Controller\Home' => 'Landlord\Controller\HomeController',
            'Landlord\Controller\About' => 'Landlord\Controller\AboutController',
        ),
    ),
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help. I am looking for a regex that would match the
Im looking for some help regarding to put a save like confirmation if some
I'm looking for some help from developers who are know android development. We have
I am looking for some help with grep, or grep like tools. This includes
I am looking for some help and would be VERY grateful for it. I
I am looking for some help and would be VERY grateful for it. I
I am looking for some help on creating a regular expression that would work
I'm looking for some help to add text to a listview with four columns.
Looking for some help! I need to split a string at the last occurrence
looking for some help with images referenced within the stylesheet. I have no problems

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.