简体   繁体   中英

Zend - Couldnt load Zend/Application.php (failed to open stream)?

I have a structure as below (I'm using Zend 1.9.6):

http://farm3.static.flickr.com/2605/4112306785_fc80d39833_o.gif
(I'm really sorry. I'm not enough reputation.)

When I run program, I get an error:

*Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in C:\\xampp\\htdocs\\myzend\\index.php on line 25 Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path=';C:\\xampp/application/modules/admin/models;.;C:\\xampp\\php\\PEAR') in C:\\xampp\\htdocs\\myzend\\index.php on line 25*

Here is my 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();

Here is my 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

I have search many times on the internet but nothing found helpful. Please help me! Thank so much. This is my first application with Zend.

http://www.mediafire.com/download/rni7f3af3n214kx/myzend.rar

The error means PHP can't find the file Zend/Application.php that you're trying to require in. By convention, you'd have a copy of Zend Framework in your library folder, so this file should be at library/Zend/Application.php .

Your index.php adds the library folder to the include path, which is what tells PHP to look in this folder when including files. However I don't think the path you've put in is correct, which is probably the cause of the error. You have:

set_include_path(implode(PATH_SEPARATOR, array(
   realpath(APPLICATION_PATH . '/library'),
   APPLICATION_PATH . '/modules/admin/models' ,
   get_include_path(),
)));

but this should be:

set_include_path(implode(PATH_SEPARATOR, array(
   realpath(APPLICATION_PATH . '/../library'),
   APPLICATION_PATH . '/modules/admin/models' ,
   get_include_path(),
)));

Edit : Your ZF project archive worked for me with two small fixes:

  • I fixed the filename of application.ini in application/configs (it was misspelt - possibly just an issue in your rar archive).
  • I changed the defaultModule in application.ini from Default to default .

The page then loaded for me. I didn't get the Zend/Application.php error you reported in your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM