【问题标题】:Zend - Couldnt load Zend/Application.php (failed to open stream)?Zend - 无法加载 Zend/Application.php(无法打开流)?
【发布时间】:2013-05-22 08:43:13
【问题描述】:

我的结构如下(我使用的是 Zend 1.9.6):

http://farm3.static.flickr.com/2605/4112306785_fc80d39833_o.gif
(真的很抱歉。我的名声不够。)

当我运行程序时,我得到一个错误:

*警告:require_once(Zend/Application.php):无法打开流:第 25 行的 C:\xampp\htdocs\myzend\index.php 中没有这样的文件或目录 致命错误:require_once():无法在 C 中打开所需的 'Zend/Application.php' (include_path=';C:\xampp/application/modules/admin/models;.;C:\xampp\php\PEAR'): \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 windows zend-framework frameworks


    【解决方案1】:

    该错误意味着 PHP 找不到您尝试要求的文件 Zend/Application.php。按照惯例,您的 library 文件夹中有 Zend Framework 的副本,因此该文件应位于library/Zend/Application.php

    您的 index.php 将 library 文件夹添加到包含路径,这就是告诉 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/configs 中修复了 application.ini 的文件名(拼写错误 - 可能只是您的 rar 存档中的一个问题)。
    • 我将 application.ini 中的 defaultModuleDefault 更改为 default

    然后为我加载页面。我没有收到您在问题中报告的 Zend/Application.php 错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-27
      • 1970-01-01
      • 2013-04-20
      • 2016-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多