I get the following error when I try to run the project created by Zend Framework. Its looking for Zend/Application.php and that is available in the directory that is in my include_path. I do have read permissions on the directory.
PHP Fatal error: require_once() [function.require]:
Failed opening required 'Zend/Application.php'
(include_path='/var/www/vhosts/moderncloud.net/om/library:.:/var/www/vhosts/moderncloud.net/om
/library:') in /var/www/vhosts/moderncloud.net/om/public/index.php on
line 24
<?php
// Define path to application directory
//defined('APPLICATION_PATH')
// || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', 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(
('/var/www/vhosts/moderncloud.net/om/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();
SOLUTION:
I found it myself today. Its a problem with the option
"php_admin_value open_basedir" in my httpd configuration. I set it to
none and it started working. Alternatively, I guess I can append the Zend library
directory to the open_basedir option in my web server configuration instead of setting it to none.
Can you try replacing:
set_include_path(implode(PATH_SEPARATOR, array(
('/var/www/vhosts/moderncloud.net/om/library'),
get_include_path(),
)));
with
$siteRootDir = dirname($_SERVER['DOCUMENT_ROOT']);
set_include_path(
$siteRootDir . '/library' . PATH_SEPARATOR
. $siteRootDir . '/application' . PATH_SEPARATOR
. get_include_path()
);
Hope it works for you
If possible, remove the existing zend framework installation and install ZF using PEAR. It will be easier to update later on:
pear channel-discover zend.googlecode.com/svn
pear install zend/zend
It will also use PEAR's include_path, so it should solve your problem.
If you can't use pear, try to use relative path with your include path:
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
This problem generated due to :
- Inside Public folder in index.php file.
or
- Inside library folder :- Just check in library folder there is a folder of Zend present in library folder or not.If not present zend folder then download from zend framework and save in library folder.
=> In index.php copy the following code and replace it.
<?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';
require_once 'library/Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();