views:

37

answers:

2

I am newbie in zend framework ,

a simple question :

in my IndexController file , I want to instance new class.

I put the file of class declaration under /library

and of course its in the include path (index.php)

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

I get an error :

Fatal error: Class 'Profile' not found in ....

what is the way to auto load this class ?

thanks!

+2  A: 

you have to put this class in models ...not in library and use

set_include_path('./application/models'); in index.php
Richa
thanks its work!
Haim Evgi
+5  A: 

Alternatively, you could add namespaces to the autoloader.

So if your class was named My_Profile, stored in a the file library/My/Profile.php, you could add the following to your application/config/application.ini:

autoloadernamespaces[] = "My_"

or in your Bootstrap class's _initAutoload() method:

Zend_Loader_Autoloader::getInstance()->registerNamespace('My_');

See Zend Framework: Autoloading a Class Library

David Weinraub