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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:49:05+00:00 2026-06-13T06:49:05+00:00

I have ZF 1 where i got working Bootstrap.php with lots of routing and

  • 0

I have ZF 1 where i got working Bootstrap.php with lots of routing and other preDispatch stuff.

But in ZF2 there is no Bootstrap.php concept anymore? Or i mean how can i do this same in Zf2?

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

  protected function _initPdispatch() {
    $this->bootstrap('frontController');
    require_once APPLICATION_PATH . '/controllers/plugin/LanguageSelector.php';
    $plugin = new LanguageSelector();
    $front = Zend_Controller_Front::getInstance();
    $front->registerPlugin($plugin);
    return $plugin;
  }

  protected function _initRoutes() {
    $front = Zend_Controller_Front::getInstance();
    $router = $front->getRouter();
    $dynamic1 = new Zend_Controller_Router_Route(
                    '/:variable1',
                    array(
                        'controller' => 'router',
                    ),
//              array('variable1' => '^[a-zA-Z0-9_-]*$')
                    array('variable1' => '^[\w.-]*$')
    );
    $router->addRoute('dynamic1', $dynamic1);
  }
  • 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-13T06:49:07+00:00Added an answer on June 13, 2026 at 6:49 am

    One of the best features of ZF2 is something that I actually hated at first, which are the routes. It’s both great and annoying because now you’re required to set the routes for all of your modules.

    Part of understanding ZF2 (more quickly) is understanding modules. If you can get past this, you will begin to adapt much more quickly. (At least that’s how it was for me). So, what in ZF2 is a module? Anything!

    Anyway, all of the config files for every module and for the application eventually get merged within the Zend Framework, so that means you can define routes anywhere really.

    That said, you don’t need to “bootstrap” your routes anymore as that is part of your ModuleName/config/module.config.php file. now.

    Now, I’m not an expert on regex routes within ZF2, but it would be something like:

    // MyModule/config/module.config.php
    return array(
        'router' => array(
            'routes' => array(
                'dynamic1' => array(
                    'type' => 'regex',
                    'options' => array(
                        'route' => '/[:variable1]'
                    )
                )
            )
        )
    );
    

    Somewhere in there you define the regex. Additionally, I saw in their docs that you can also define a regex route manually:

    use Zend\Mvc\Router\Http\Regex;
    
    // ...
    
    $route = Regex::factory(array(
        'regex' => '/blog/(?<id>[a-zA-Z0-9_-]+)(\.(?<format>(json|html|xml|rss)))?',
        'defaults' => array(
            'controller' => 'Application\Controller\BlogController',
            'action'     => 'view',
            'format'     => 'html',
        ),
        'spec' => '/blog/%id%.%format%',
    ));
    
    $router->addRoute($route);
    

    You should be able to add this as a service or put it in onBootstrap() within the Application module if you’re using the Skeleton Application.

    Keep in mind, that was their example and again, I’m not an expert on this. Here is some more information.

    Hope this helps!

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

Sidebar

Related Questions

I got the twitter bootstrap dropdown buttons successfully working, but I have a tiny
I am compiling PHP and PostgreSQL myself. I have got things working fine. There
I have got it working up to the third select list. But there are
I am certain I have got this working in the past, but it doesn't
I am working with IronPython and have got it working somehow. Though, there seems
I have got experience working in Spring framework, but i find it very difficult
I have got the bootstrap carousel working on my web page and i want
I have got tinyMCE working in the django admin, but all the popups are
I'm following the Django-CMS introductory tutorial and have got everything working up to the
I have got one weird issue. I am working on an asp .net mvc

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.