Reputation: 125456
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!
Upvotes: 1
Views: 1571
Reputation: 14184
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
Upvotes: 6
Reputation: 1709
you have to put this class in models ...not in library and use
set_include_path('./application/models'); in index.php
Upvotes: 2