Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in /var/w

17,835

Solution 1

For Ubuntu.
If you install ZendFramework package. i.e. sudo apt-get install zend-framework
It will put zend library files in /usr/share/php/libzend-framework-php/Zend/ folder
you have to just copy and paste that Zend/ folder into /user/share/php/
Run the following command in terminal.

cd /usr/share/php
sudo cp -R libzend-framework-php/Zend/ Zend

Solution 2

Put your index file in "public" directory.

Or if you want or cannot include files from parent directory you need to change this line:

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

To

set_include_path(implode(PATH_SEPARATOR, array(
  realpath(APPLICATION_PATH . '/library'), // Here we have change
  get_include_path(),
)));

Of course I assume that you have already putted your Zend Files into library/Zend

You also need to remember to put .htaccess file with "deny from all" to your application, library, and any other directory you don't want users to get access to.

Btw. This method of including library is quite old and not recommended.

Share:
17,835

Related videos on Youtube

user2605708
Author by

user2605708

Updated on September 15, 2022

Comments

  • user2605708
    user2605708 over 1 year

    my index file is this

    <?php
    ini_set( "short_open_tag", 1 );
    ini_set( "display_errors", 1 );
    // 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'
    );
    
    // Let 'er rip
    $application->bootstrap()->run();
    

    when i run that

    Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in /var/www/Giftercity_backup/index.php on line 18 Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path=':.:/usr/share/php:/usr/share/pear') in /var/www/Giftercity_backup/index.php on line 18

  • Angel.King.47
    Angel.King.47 almost 10 years
    I would create a symlink instead but you answer is essentially what I do
  • Vic Seedoubleyew
    Vic Seedoubleyew about 8 years
    There is now a troubleshooting checklist for this frequent error here : stackoverflow.com/a/36577021/2873507