Search code examples
zend-frameworkzend-db-table

Zend Framework Class 'Table' not found error


I have basic zend framework installation. I create new db table models/tables/User.php

<?php 

require_once 'Zend/Db/Table/Abstract.php';

class UserTable extends Zend_Db_Table_Abstract
{
    protected $_name = 'user';
}

And later in IndexController I make a call to table:

public function indexAction()
{

        $userTable = new UserTable();
}

But I get fatal error: Fatal error: Class 'UserTable' not found. What I do wrong ?

Your help would be appreciated.


Solution

  • I think the issue is with the naming. In Zend the classes are autoloaded according to its name.

    If the name of the file is User.php, the class name should be User
    If the file is in the location Models/Usertable.php the class name should be Models_Usertable

    There are several methods of autoloading techniques in ZF. Check this manual learning.autoloading.design