我有一个结构如下(我使用Zend 1.9.6):
http://farm3.static.flickr.com/2605/4112306785_fc80d39833_o.gif我真的很抱歉。我的名声不够。)
当我运行程序时,我得到一个错误:
*警告:require_once(Zend/Application.php): failed to open stream: No such file or directory in C:'xampp'htdocs'myzend'index.php on line 25致命错误:require_once():未能打开所需的'Zend/application .php' (include_path=';C:'xampp/application/modules/admin/models;.;C:'xampp'php'PEAR')在C:'xampp'htdocs'myzend'index.php第25行*
这是我的index.php
<?php
date_default_timezone_set('Asia/Ho_Chi_Minh');
// Define base path obtainable throughout the whole application
defined('BASE_PATH')
|| define('BASE_PATH', realpath(dirname(__FILE__) . '/../..'));
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', BASE_PATH . '/application');
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/library'),
APPLICATION_PATH . '/modules/admin/models' ,
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();
这是我的application.ini
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.defaultModule = "Default"
resources.frontController.defaultControllerName = "Index"
resources.frontController.defaultAction ="index"
resources.modules = ""
resources.layout.layout = "layout"
resources.layout.layoutpath = APPLICATION_PATH "/layouts"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
我在网上搜索了很多次,但没有找到有用的。请帮帮我!非常感谢。这是我使用Zend的第一个应用程序。
http://www.mediafire.com/download/rni7f3af3n214kx/myzend.rar
这个错误意味着PHP找不到你想要的文件Zend/Application.php
。按照惯例,在library
文件夹中有一个Zend Framework的副本,所以这个文件应该在library/Zend/Application.php
。
您的index.php将库文件夹添加到包含路径中,这是告诉PHP在包含文件时查找该文件夹的原因。但是,我认为您输入的路径不正确,这可能是导致错误的原因。你有:
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/library'),
APPLICATION_PATH . '/modules/admin/models' ,
get_include_path(),
)));
但这应该是:
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
APPLICATION_PATH . '/modules/admin/models' ,
get_include_path(),
)));
编辑:你的ZF项目存档为我工作,有两个小的修复:
- 我修复了application.ini在application/configs中的文件名(它拼写错误-可能只是你的rar存档中的问题)。
- 我将application.ini中的
defaultModule
从Default
更改为default
。