views:

1584

answers:

2

I'm trying out the zend framework classes for the first time. I am interested in using some of the individual classes for now. Reading the documentation and some other q's here and in blogs I've tried three ways to load the classes

    //attempt 1 - using zend loader
require_once('library\Zend\Loader.php');
Zend_Loader::loadClass('Zend_Date');

    //attempt 2 - direct class load
require_once('library\Zend\Date.php');

    // attempt 3 - auto load
set_include_path('D:\wamp\www\testPages\zend_test\library\Zend' . PATH_SEPARATOR . get_include_path());
require_once 'Loader\Autoloader.php';


$date = new Zend_Date();

// Output of the desired date
print $date->get();

my folder structure is:

  • zend_test(folder)
    -- testLoad.php (the above code lives there)
    -- library(folder)
    --- zend(doler)
    ---- (the zend libs and sub folders)

I get the following error messages: attempt 1

Warning: include(Zend\Date.php) [function.include]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 83

Warning: include() [function.include]: Failed opening 'Zend\Date.php' for inclusion (include_path='.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 83

Warning: require_once(Zend/Exception.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 87

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Exception.php' (include_path='.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 87

attempt2

Warning: require_once(Zend/Date/DateObject.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Date.php on line 25

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Date/DateObject.php' (include_path='.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Date.php on line 25

atempt3

Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Loader\Autoloader.php on line 24
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_path='D:\wamp\www\testPages\zend_test\library\Zend;.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Loader\Autoloader.php on line 24

Am i missing something?

+2  A: 

Your include path should read:

include_path='D:\wamp\www\testPages\zend_test\library;.;C:\php5\pear

When it tries to load the class Zend_Date it looks for a folder called Zend in the include path, with a file called Date.php in it.

All 3 of your methods should work with this corrected, and I recommend attempt 3.

David Caunt
A: 

used method 3 and did this to get it working:

set_include_path('D:/wamp/www/zendTest/library/');   
require_once 'Zend/Loader/Autoloader.php';

Zend_Loader::loadClass('Zend_Date'); //or whatever zen class
Joe