2013-06-12 168 views
1

我設置了Zend框架2上1 & 1共同主辦的網站繼skeleton application tutorial,和我在與應用模塊沒有加載問題:Zend框架2 1 1

Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 
'Module (Application) could not be initialized.' in /homepages/etc/etc/etc/zendskeletonapplication-master/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:175 

我發現有人使用same error,但他們只是在單元測試中得到它,而且我在加載網站時得到它。儘管如此,我已經嘗試改變module_paths的設置,但錯誤不會改變。

我猜這是某種1 &模塊加載的特定問題。爲了讓事情這麼遠,我已經不得不添加這些設置的.htaccess(設置使用PHP 5.4.16服務器,儘管「PHP6」提):

AddHandler x-mapp-php6 .php 
AddType x-mapp-php6 .php 
+0

我非常懷疑1&1正在運行PHP6 – chrislondon

+0

正如我原來的評論中提到的那樣,這些是他們使用PHP 5.4所需的設置。他們解釋了爲什麼在[本頁](http://faq.1and1.co.uk/scripting/php/5.html)。 – Joren

回答

0

我不認爲這是1 & 1問題。當您在模塊中設置錯誤時通常會發生此問題。

檢查以下文件以確保它們存在並設置正確。它看起來像您正在使用的應用程序框架教程,以便確保下列文件完全匹配:

/module/Application/Module.php

<?php 
/** 
* Zend Framework (http://framework.zend.com/) 
* 
* @link  http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository 
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) 
* @license http://framework.zend.com/license/new-bsd New BSD License 
*/ 

namespace Application; 

use Zend\Mvc\ModuleRouteListener; 
use Zend\Mvc\MvcEvent; 

class Module 
{ 
    public function onBootstrap(MvcEvent $e) 
    { 
     $eventManager  = $e->getApplication()->getEventManager(); 
     $moduleRouteListener = new ModuleRouteListener(); 
     $moduleRouteListener->attach($eventManager); 
    } 

    public function getConfig() 
    { 
     return include __DIR__ . '/config/module.config.php'; 
    } 

    public function getAutoloaderConfig() 
    { 
     return array(
      'Zend\Loader\StandardAutoloader' => array(
       'namespaces' => array(
        __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, 
       ), 
      ), 
     ); 
    } 
} 

/模塊/ Application/config/module.config.php

<?php 
/** 
* Zend Framework (http://framework.zend.com/) 
* 
* @link  http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository 
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) 
* @license http://framework.zend.com/license/new-bsd New BSD License 
*/ 

return array(
    'router' => array(
     'routes' => array(
      'home' => array(
       'type' => 'Zend\Mvc\Router\Http\Literal', 
       'options' => array(
        'route' => '/', 
        'defaults' => array(
         'controller' => 'Application\Controller\Index', 
         'action'  => 'index', 
        ), 
       ), 
      ), 
      // The following is a route to simplify getting started creating 
      // new controllers and actions without needing to create a new 
      // module. Simply drop new controllers in, and you can access them 
      // using the path /application/:controller/:action 
      'application' => array(
       'type' => 'Literal', 
       'options' => array(
        'route' => '/application', 
        'defaults' => array(
         '__NAMESPACE__' => 'Application\Controller', 
         'controller' => 'Index', 
         'action'  => 'index', 
        ), 
       ), 
       'may_terminate' => true, 
       'child_routes' => array(
        '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(
          ), 
         ), 
        ), 
       ), 
      ), 
     ), 
    ), 
    'service_manager' => array(
     'abstract_factories' => array(
      'Zend\Cache\Service\StorageCacheAbstractServiceFactory', 
      'Zend\Log\LoggerAbstractServiceFactory', 
     ), 
     'aliases' => array(
      'translator' => 'MvcTranslator', 
     ), 
    ), 
    'translator' => array(
     'locale' => 'en_US', 
     'translation_file_patterns' => array(
      array(
       'type'  => 'gettext', 
       'base_dir' => __DIR__ . '/../language', 
       'pattern' => '%s.mo', 
      ), 
     ), 
    ), 
    'controllers' => array(
     'invokables' => array(
      'Application\Controller\Index' => 'Application\Controller\IndexController' 
     ), 
    ), 
    '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', 
     ), 
    ), 
); 
+0

謝謝你的發表!我檢查了這些文件,當它們的_contents_完全匹配時,它們的文件名大小寫不是_not_。 事實證明,1&1在bash(SSH)中定義了一個用於解壓的別名(我對我的別名進行了三重檢查,以確保它不是來自我的別名之一)「unzip -L」,這使得它提取的所有內容都爲小寫。我只是在我的本地機器上解壓並上傳文件,而且所有內容都在瞬間啓動並運行。 :) – Joren