php – 当克隆到本地服务器时,ZF2项目停止工作
我想知道为什么当我将我的ZF2项目克隆到本地机器进行一些测试时,它会完全停止工作.
在我的本地机器上,我有两个子文件夹,一个带有cakePHP项目,另一个带有我已克隆的ZF2. cakePHP项目工作正常,因为它首先存在,但ZF2,当我尝试访问公共文件夹时它打印我: {"error":"Something went wrong"} 一个非常普遍的错误……我不知道发生了什么. 我尝试过一些常规的调试尝试 ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(E_ALL); 根本没有成功,我还检查了.htaccess RewriteBase指令以匹配我的子文件夹,同时也完成了数据库配置. 我在项目中研究了一下,显示错误的文件是module / RestfulV2_2 / Module.php(读取我发现的README.md是ZF2 Restful Module Skeleton的一部分): /** * @param MvcEvent $e * @return null|ZendHttpPhpEnvironmentResponse */ public function errorProcess(MvcEvent $e) { /** @var ZendDiDi $di */ $di = $e->getApplication()->getServiceManager()->get('di'); $eventParams = $e->getParams(); /** @var array $configuration */ $configuration = $e->getApplication()->getConfig(); $vars = array(); if (isset($eventParams['exception'])) { /** @var Exception $exception */ $exception = $eventParams['exception']; if ($configuration['errors']['show_exceptions']['message']) { $vars['error-message'] = $exception->getMessage(); } if ($configuration['errors']['show_exceptions']['trace']) { $vars['error-trace'] = $exception->getTrace(); } } if (empty($vars)) { $vars['error'] = 'Something went wrong'; } /** @var PostProcessorAbstractPostProcessor $postProcessor */ $postProcessor = $di->get( $configuration['errors']['post_processor'],array('vars' => $vars,'response' => $e->getResponse()) ); $postProcessor->process(); if ( $eventParams['error'] === ZendMvcApplication::ERROR_CONTROLLER_NOT_FOUND || $eventParams['error'] === ZendMvcApplication::ERROR_ROUTER_NO_MATCH ) { $e->getResponse()->setStatusCode(ZendHttpPhpEnvironmentResponse::STATUS_CODE_501); } else { $e->getResponse()->setStatusCode(ZendHttpPhpEnvironmentResponse::STATUS_CODE_500); } $e->stopPropagation(); return $postProcessor->getResponse(); } 在我的index.php中调用错误的行是: ZendMvcApplication::init(require 'config/application.config.php')- run(); 我发现错误函数以某种方式调用的唯一一行是我的modele.php中的这一行: $sharedEvents->attach('ZendMvcApplication',MvcEvent::EVENT_DISPATCH_ERROR,array($this,'errorProcess'),999); 你能帮帮我解决这个问题吗?我对ZF2缺乏经验,但我知道使用cakePHP使其工作,你需要清除缓存文件夹.在ZF2中有任何类似的过程吗?我应该虚拟化两台服务器以避免冲突吗? 先感谢您. 编辑:我已经制作了虚拟主机,以避免我的两个框架之间的任何可能的冲突,但错误输出仍然是相同的. EDIT2:这是我的application.config.php文件: return array( // This should be an array of module namespaces used in the application. 'modules' => array( 'Restful','MvlabsSnappy','Qrcode','Application','RestfulV2','RestfulV2_2' ),// These are various options for the listeners attached to the ModuleManager 'module_listener_options' => array( // This should be an array of paths in which modules reside. // If a string key is provided,the listener will consider that a module // namespace,the value of that key the specific path to that module's // Module class. 'module_paths' => array( './module','./vendor',),// An array of paths from which to glob configuration files after // modules are loaded. These effectively override configuration // provided by modules themselves. Paths may use GLOB_BRACE notation. 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php',// Whether or not to enable a configuration cache. // If enabled,the merged configuration will be cached and used in // subsequent requests. //'config_cache_enabled' => $booleanValue,// The key used to create the configuration cache file name. //'config_cache_key' => $stringKey,// Whether or not to enable a module class map cache. // If enabled,creates a module class map cache which will be used // by in future requests,to reduce the autoloading process. //'module_map_cache_enabled' => $booleanValue,// The key used to create the class map cache file name. //'module_map_cache_key' => $stringKey,// The path in which to cache merged configuration. //'cache_dir' => $stringPath,// Whether or not to enable modules dependency checking. // Enabled by default,prevents usage of modules that depend on other modules // that weren't loaded. // 'check_dependencies' => true,// Used to create an own service manager. May contain one or more child arrays. //'service_listener_options' => array( // array( // 'service_manager' => $stringServiceManagerName,// 'config_key' => $stringConfigKey,// 'interface' => $stringOptionalInterface,// 'method' => $stringRequiredMethodName,// ),// ) // Initial configuration with which to seed the ServiceManager. // Should be compatible with ZendServiceManagerConfig. // 'service_manager' => array(),); 解决方法
首先,我将打开index.php或任何用作初始文件(DirectoryIndex)的内容,并暂时完全用一些基础和简单的内容替换整个内容,例如这两行:
<?php phpinfo(); 然后确保它在那之后开始工作 – 使用那个只显示你的php配置的简单代码.因此,我们将发现服务器配置,权限等没有错误,并且没有任何东西阻止您的脚本运行. 然后我会在您的旧项目位置执行相同操作,以便从该位置获取phpinfo()并浪费一些时间来尝试比较它们.也许你错过了重要的事情,现在你会看到它. 如果没有 – 下一步我会检查你的数据库连接,如果你的项目使用任何数据库……还有一些非常简单的命令,如connect,bind,…. 最后,我将尝试从开始逐步恢复原始项目内容,并查看它将失败的步骤.没有任何输出也没关系 – 你可以把echo __LINE__. ‘有效!< br />‘;在块之间,所以你的index.php看起来像: <?php // original code block 1 echo __LINE__ . ' works!<br/>'; // original code block 2 echo __LINE__ . ' works!<br/>'; 你会在浏览器中看到它失败的地方. 这是我的调试主体的基本描述,但希望它会有所帮助. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |