2013-05-22 77 views
0

我有一個結構如下(我使用Zend 1.9.6):(我真的很抱歉,我沒有足夠的聲譽。)
Zend - 無法加載Zend/Application.php(未能打開流)?

http://farm3.static.flickr.com/2605/4112306785_fc80d39833_o.gif

當我運行程序,我得到一個錯誤:

*警告:require_once(Zend/Application.php):未能打開流:沒有這樣的文件或目錄在C:\ xampp \ htdocs \ myzend \ index.php在線25 致命錯誤:require_once():失敗打開所需'Zend/Application.php'(include_path ='; C:\ xampp/application/modules/admin/models;。; C:\ xampp \ php \ PEA R')在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

回答

0

的錯誤意味着PHP不能找到你想要求在文件Zend/Application.php。按照慣例,你必須Zend框架的在你的文件夾library副本,所以這文件應該在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項目檔案工作對我來說有兩個小的修正:

  • 我固定的應用程序的文件名.ini在應用程序/配置文件中(這是拼寫錯誤 - 可能只是你的rar檔案中的一個問題)。
  • 我將application.ini中的defaultModuleDefault更改爲default

然後頁面爲我加載。我沒有得到你在問題中報告的Zend/Application.php錯誤。