Autoloading Zend Framework classes

爷,独闯天下 提交于 2019-12-10 10:05:20

问题


Here I am getting this error whenI tried to run a downloaded zend project what is this error and how it can be solved

Warning: require_once(Zend/Application.php) [function.require-once]:
failed to open stream: No such file or directory in
C:\xampp\htdocs\sandbox\public\index.php on line 18

index.php

<?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'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    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();

回答1:


You need to include the Zend Framework "library" on your include path. You can either do this globally in your php.ini file's include_path directive or more simply in your application's index.php file, eg

set_include_path(implode(PATH_SEPARATOR, array(
    '/path/to/zend/framework/library',
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path()
)));

If it's a standard ZF app, there will probably already be something like that in index.php, just add the ZF path to the array.

If you do make any changes to your php.ini file, don't forget to restart Apache.




回答2:


I think the message is telling you it can't find the needed files.

Have you added Zend library to your include path as recommended in the docs?




回答3:


realpath(APPLICATION_PATH . '/../../php/ZendFramework/library')

Things don't happen by magic. You have to provide the correct include_path. From what I see (C:\xampp\htdocs\sandbox\public\index.php) you have to go two directories back to C:\xampp and then up again into your library.



来源:https://stackoverflow.com/questions/6840350/autoloading-zend-framework-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!