Zend Framework Form not found
In my public/index.php
I define the include path:
开发者_开发百科// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
'/var/www/php_include/zend/1.11.7/library',
'/var/www/php_include/application',
get_include_path(),
)));
In my IndexController I want to reference to my Form with
new Form_Login();
But there I receive the error:
Fatal error: Class 'LoginForm' not found in /var/www/php_include/application/controllers/LoginController.php on line 31
Form is under application/forms/Login.php
:
class Form_Login extends Zend_Form
{
public function init()
{
get_include_path()
before using new LoginForm()
throws:
/var/www/php_include/application/../library:/var/www/php_include/zend/1.11.7/library:/var/www/php_include/application:/var/www/php_include/application/forms:.:/var/www/php_include:/usr/share/pear/PEAR
Anyone knows how to get this working?
The autoloader won't find it me sphinx. Just add your forms/
path to your include path.
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
'/var/www/php_include/zend/1.11.7/library',
'/var/www/php_include/application',
'/var/www/php_include/application/forms',
get_include_path(),
)));
Now rename your file to LoginForm.php
and your class-name to LoginForm
Then use
new LoginForm();
This is the exact same way I have done it with my projects, except my forms-dir is placed in views and the includepath is set with application.ini
Update
This is part of my Bootstrap class:
function _initAutoloader() {
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
return $autoloader;
}
your class should be called
Form_LoginForm
to be found by the autoloader.
But you should change it to Form_Login
and forms/Login.php
try
new Default_Form_LoginForm();
精彩评论