Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoloading Zend Framework classes

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 Answers

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.

like image 152
Phil Avatar answered Nov 24 '25 22:11

Phil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!