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 7018775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:05:46+00:00 2026-05-27T23:05:46+00:00

I have a questiom regarding the Zend Framework 2: I have library/System and library/Zend.

  • 0

I have a questiom regarding the Zend Framework 2:

I have
library/System and library/Zend. the system is my custom library, which I want to configure de aplication (routes, modules, etc., and redirect user to correct module, controller and/or action).

I don’t want to do this inside each application/modules/ModuleName/Module.php file. So, my library/System can do everything related to application configuration.

  • 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-05-27T23:05:46+00:00Added an answer on May 27, 2026 at 11:05 pm

    As said in the comments above: register to the bootstrap-event and add new routes there:

    <?php
    
    namespace Application;
    
    use Zend\Module\Manager,
        Zend\EventManager\StaticEventManager;
    
    class Module
    {
        public function init(Manager $moduleManager)
        {
            $events = StaticEventManager::getInstance();
            $events->attach('bootstrap', 'bootstrap', array($this, 'initCustom'), 100);
        }
    
        public function initCustom($e)
        {
            $app = $e->getParam('application');
            $r = \Zend\Mvc\Router\Http\Segment::factory(array(
                    'route'    => '/test',
                    'defaults' => array(
                        'controller' => 'test'
                    )
                )
            );
            $app->getRouter()->addRoute('test',$r);
        }
    }
    

    $app = $e->getParam('application'); does return an instance of Zend\Mvc\Application. Have a look there to see which additional parts you can get there. The bootstrap event is fired before the actual dispatching does happen.

    Note that the ZendFramework 1 routes are not always compatible to the ZendFramework 2 ones.

    Update to comments

    public function initCustom($e)
    {
        $app = $e->getParam('application');
        // Init a new router object and add your own routes only
        $app->setRouter($newRouter);
    }
    

    Update to new question

    <?php
    
    namespace Application;
    
    use Zend\Module\Manager,
        Zend\EventManager\StaticEventManager;
    
    class Module
    {
        public function init(Manager $moduleManager)
        {
            $events = StaticEventManager::getInstance();
            $events->attach('bootstrap', 'bootstrap', array($this, 'initCustom'), 100);
        }
    
        public function initCustom($e)
        {
            $zendApplication = $e->getParam('application');
            $customApplication = new System\Application();
            $customApplication->initRoutes($zendApplication->getRouter());
            // ... other init stuff of your custom application
        }
    }
    

    This only happens in one zf2 module (named Application which can be the only one as well). This doesn’t fit your needs? You could:

    • extend a custom module autoloader
    • extend Zend\Mvc\Application for your own logic
    • make your code zf2-compatible
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a question regarding something which has been bugging me for some time now.I'm
I've started reading on zend framework and it's use with Doctrine and have implemented
I have question regarding the service and activity. I have one service which calls
Zend Framework/Doctrine 2 application.: /app /modules /blog /controllers /BlogController.php /domain /entities /services /PostService.php /repositories
I have question regarding shared memory segmentation in c using POSIX system calls. Is
have on question about the Zend Framework 2. In my Application i have a
I have just encountered something rather strange, I use the Zend Framework 1.10 with
I am writing my own Graph library Graph++ , I have question regarding what
In the Zend Framework library, the current practice (circa 1.10.8) is that library components
I have been using Zend Framework for a while now. I am having an

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.