views:

239

answers:

2

Locally, on my xampp installation, the Zend folder is under PEAR\Zend, and Pear is in the include path. So when I do require_once "Zend\Date.php" there is no problem.

However, on my domain (Hostmonster), that's not the case. I have no idea where the Zend folder is, although doing phpinfo(); seems to indicate that Zend Framework is definitely available. I asked the host, and they told me to include zend_extension="/usr/local/Zend/lib/Optimizer-3.3.9/php-5.2.x/ZendOptimizer.so" at the bottom of the php.ini file, which didn't help at all.

Also, I don't know what that statement in the php.ini file even does. Could anyone please help?

+1  A: 

Perhaps you could upload the Zend library to your shared hosting account in a directory like /home/your_account/public_html/zend.

Then modify (or create if it doesn't exist) a php.ini file in your webroot directory /home/your_account/public_html. Add the following:

include_path = .:/home/your_account/public_html/Zend

Note: this will override any default include paths set by PHP. The . represents the current directory and : separates the different paths.

Now in your PHP file you can add at the top:

require_once 'Zend/Date.php';
jwhat
+3  A: 

Enabling Zend extension as you mentioned above is not relevant to including ZF classes which you want to do. Download ZF and upload it to wherever you like in public_html folder if that's not available somewhere yet. use set_include_path() and go! sample code below:

<?php
    // Define relative path to ZendFramework in public_html
    define('ZF_PATH', '/../../../lib/php/zendframework');

    // Define path to application directory
    defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

    // Define real path to ZendFramework if it's not yet included in include_path
    if(!strpos(get_include_path(), 'zendframework'))
        define('ZF_REAL_PATH', realpath(APPLICATION_PATH . ZF_PATH));
    else define('ZF_REAL_PATH', '');

    // Updating include_path
    set_include_path(implode(PATH_SEPARATOR, array(ZF_REAL_PATH, get_include_path(),)));

    // Done! the rest of the code might be unnecessary in your case.
    require 'Zend/Application.php'; 

    // Create application, bootstrap, and run
    $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
    $application->bootstrap()->run();

This might seem kinda complicated for the case of adding a directory to include path but it's the most common way ZF apps use, I think.

Sepehr Lajevardi