Zend Debug不输出服务定位器

I'm having difficulty debugging objects using zend-db retrieved from the service-manager.

I have a module with the following code in the onBootstrap event:

public function onBootstrap(MvcEvent $e)
    $eventManager = $e->getApplication()->getEventManager();
    $moduleRouteListener = new ModuleRouteListener();
    $moduleRouteListener->attach($eventManager);        
    $translator = $e->getApplication()->getServiceManager()->get('translator');
    $translator->setLocale(\Locale::acceptFromHttp($request->getServer('HTTP_ACCEPT_LANGUAGE')))
               ->setFallbackLocale(System::config('i18n/fallback_language'));   
    \Zend\Debug\Debug::dump($translator);        
    die();
}

I'm not quite sure why, but for some reason when I pass the translator to the debug it blanks out the screen and execution halts. What's interesting is that it seems to be an issue when using other objects too during this phase.:

I'm not quite sure what's going on here.

I do know that these objects are valid created objects as the application works but for some reason I cannot debug dump anything from the service locator.

Here is a list of my ini settings in case it has to do with a php settings.

Environment::iniSet('max_execution_time',0);
Environment::iniSet('display_errors','1');
Environment::iniSet('display_startup_errors',1);
Environment::iniSet('ignore_user_abort',1);
Environment::iniSet('date.timezone','America/New_York');
Environment::iniSet('mime_magic.magicfile',1);
Environment::iniSet('zend.ze1_compatibility_mode',0);  

Any help appreciated.

I think you should consider to attach your (translator) services using some mvc event. So for example; you want to do translation inside a controller or during rendering, then get the MvcEvent::EVENT_DISPATCH ('dispatch') event or MvcEvent::EVENT_RENDER ('render') event and attach the translator when that event is triggered.

You can do it like this:

/**
 * @param EventInterface|MvcEvent $event
 */
public function onBootstrap(EventInterface $event)
{
    $application    = $event->getApplication();
    $eventManager   = $application->getEventManager();

    // Attach translator on dispatch Event
    $eventManager->attach(MvcEvent::EVENT_DISPATCH, array($this, 'attachTranslator'));
}

/**
 * @param MvcEvent $event
 */
public function attachTranslator(MvcEvent $event)
{
    $application    = $event->getApplication();
    $serviceManager = $application->getServiceManager();
    $translator     = $serviceManager->get('translator');
    //do something with your translator
}

Like this you make sure you get the translator only when you need it (on dispatch or on render) and you make sure that before you get it all of the application bootstrapping has finished...