2014-01-12 38 views
2

一位朋友问我如何将他使用Zend Framework开发的站点迁移到另一台服务器。我复制所有文件和本地导入了数据库,在测试中,下列消息显示在浏览器中:使用未定义的常量APPLICATION_ENV

Notice: Use of undefined constant APPLICATION_ENV - assumed 'APPLICATION_ENV' in C: \ wamp \ www \ zend \ new \ public_html \ index.php on line 5

Warning: require_once (Zend/Application.php): failed to open stream: No such file or directory in C: \ wamp \ www \ zend \ new \ public_html \ index.php on line 10

Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path = 'C: \ php. \ Pear') in C: \ wamp \ www \ zend \ new \ public_html \ index.php on line 10

的代码看起来很混乱,我无法找到问题的是什么都没有改变。

我不知道Zend,需要一只手。

回答

1

http://framework.zend.com/manual/1.12/en/zend.application.quick-start.html记载:

You may note that the application environment constant value looks for an environment variable "APPLICATION_ENV". We recommend setting this in your web server environment. In Apache, you can set this either in your vhost definition, or in your .htaccess file. We recommend the following contents for your public/.htaccess file:

我建议在看虚拟主机/阿帕奇/ nginx的/等配置的旧服务器,并寻找类似SetEnv APPLICATION_ENV

3

如果您使用ZF1在公开/ index.php文件把这个:

// Define application environment 
defined('APPLICATION_ENV') 
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development')); 

,或者您也可以编辑你的虚拟主机配置加入这一行:

SetEnv APPLICATION_ENV "development" 
+0

有一个额外的' (反引号)......(在双引号结尾后)。 – siliconpi