我正在尝试将我的zend应用程序从本地移动到远程。在我上传GoDaddy主机上的所有文件夹后,这是我的文件夹结构:
/html
/application
/configs
/controllers
/models
/views
bootstrap.php
/library
/public
/css
/images
/js
.htaccess
index.php
我的 index.php :
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH',realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')|| define('APPLICATION_ENV',
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV'): 'production'));
//add library directory to include path
set_include_path(implode(PATH_SEPARATOR, array(
dirname(dirname(__FILE__)) . '/library',dirname(dirname(__FILE__)) .
'/application/models',dirname(dirname(__FILE__)) .
'/application/forms',dirname(dirname(__FILE__)) . '/application/views/scripts',
get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap()->run();
现在,如果我尝试输入此网址:“www.mysite.com/public/index/index”我收到此错误:
The requested URL /public/index/index/ was not found on this server.
Additionally, a 404 Not Found error was encountered while trying
to use an ErrorDocument to handle the request.
如果我只输入:“www.mysite.com/public/”我收到此警告:
Warning: require_once(/home/content/66/6902756/html/application/Bootstrap.php
[function.require-once]: failed to open stream: No such file or directory
in /home/content/66/6902756/html/library/Zend/Application.php on line 320
Fatal error: require_once() [function.require]: Failed opening
required '/home/content/66/6902756/html/application/Bootstrap.php'
(include_path='/home/content/66/6902756/html/application/../library:
/home/content/66/6902756/html/library:
/home/content/66/6902756/html/application/models:
/home/content/66/6902756/html/application/forms:
/home/content/66/6902756/html/application/views/scripts:
.:/usr/local/php5/lib/php')
in /home/content/66/6902756/html/library/Zend/Application.php on line 320
在当地,一切都运转正常
更新 在我的index.php中,我尝试过:
//it output "exists"
echo file_exists( '/home/content/66/6902756/html/application/Bootstrap.php' )?'exists':'no file found';
//where '/home/content/66/6902756/html' is my absolute hosting path
感谢
答案 0 :(得分:0)
我打赌你的问题的主要部分是你在你的包含路径中使用\
。尝试用常量DIRECTORY_SEPARATOR
替换那些。就个人而言,我会摆脱所有这些dirname(dirname(__FILE__))
。而是使用内置的APPLICATION_PATH
:
set_include_path(implode(PATH_SEPARATOR, array(
dirname( APPLICATION_PATH ) . DIRECTORY_SEPARATOR . 'library', //note one exception
APPLICATION_PATH. DIRECTORY_SEPARATOR . 'models',
APPLICATION_PATH. DIRECTORY_SEPARATOR . 'forms',
APPLICATION_PATH. DIRECTORY_SEPARATOR . 'views'. DIRECTORY_SEPARATOR .'scripts',
get_include_path())));