1

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!

Haim Evgi
  • 123,187
  • 45
  • 217
  • 223

2 Answers2

6

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

Community
  • 1
  • 1
David Weinraub
  • 14,144
  • 4
  • 42
  • 64
2

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

set_include_path('./application/models'); in index.php
PHP
  • 1,699
  • 5
  • 24
  • 43