TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Using the Zend Loader (http://www.talkphp.com/absolute-beginners/3861-using-zend-loader.html)

9three 01-13-2009 08:42 PM

Using the Zend Loader
 
I understand that the Zend Loader is to avoid having to use includes/requires all over your page?

I'm having a problem doing that though. This is what a podcast from ZF site said to do:

PHP Code:

<?php

//include paths
ini_set('include_paths'ini_get('include_paths') . PATH_SEPERATOR '../library');
require_once 
'Zend/Loader.php';

Zend_Loader::loadClass('classname');

?>

I don't really want to use the MVC as I don't really like it. I'm just trying to use the loader to avoid doing a whole bunch of requires/includes.

When I use that code I get errors:

Code:

Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in C:\Users\9three\Desktop\Server\htdocs\tests\index.php on line 5

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_path='.;C:\Users\9three\Desktop\Server\php\pear\') in C:\Users\9three\Desktop\Server\htdocs\tests\index.php on line 5

The library folder is actually one up. Its in htdocs\library\Zend. So I set it to ../Library and in the require is set to Zend/Loader.php.

All though it all matches im still getting the error. What am I doing wrong?

Wildhoney 01-13-2009 09:33 PM

Add the include paths to your Zend Framework in your index.php. Something like the following should work:

php Code:
set_include_path(implode(PATH_SEPARATOR, array(
    'C:/wamp/www/libs/ZendProject/',
    get_include_path())));

9three 01-13-2009 09:43 PM

All the components listed here:

http://framework.zend.com/manual/en/

I'm assuming that those are the class names. If I wanted to use the Zend_Mail compnent, I would do:

Zend_Loader::loadClass('Mail');

Correct?

Wildhoney 01-13-2009 11:22 PM

It would be:

php Code:
Zend_Loader::loadClass('Zend_Mail');

The class names basically follow their directories. Take Zend_Mail. Just by looking at its class name I can tell it's in Zend/Mail.php. Everything in Zend follows this structure.


All times are GMT. The time now is 10:32 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0