I was trying to read and understand some joomla core PHP code when I came across this function. It is located in libraries/joomla/table/table.php line 268. At the end of the function in line 305, it returns an object created by $tableClass, what I don't understand is, where is this $tableClass class defined? Following is a complete list of the function:

public static function getInstance($type, $prefix = 'JTable', $config = array())
    // Sanitize and prepare the table class name.
    $type       = preg_replace('/[^A-Z0-9_\.-]/i', '', $type);
    $tableClass = $prefix . ucfirst($type);

    // Only try to load the class if it doesn't already exist.
    if (!class_exists($tableClass))
        // Search for the class file in the JTable include paths.

        $paths = self::addIncludePath();
        $pathIndex = 0;

        while (!class_exists($tableClass) && $pathIndex < count($paths))
            if ($tryThis = JPath::find($paths[$pathIndex++], strtolower($type) . '.php'))
                // Import the class file.
                include_once $tryThis;

        if (!class_exists($tableClass))
            // If we were unable to find the class file in the JTable include paths, raise a warning and return false.
            JLog::add(JText::sprintf('JLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND', $type), JLog::WARNING, 'jerror');

            return false;

    // If a database object was passed in the configuration array use it, otherwise get the global one from JFactory.
    $db = isset($config['dbo']) ? $config['dbo'] : JFactory::getDbo();

    // Instantiate a new table class and return it.
    return new $tableClass($db);

1 Answer 1


Joomla is flexible and relaxed with the physical storage of Table-Classes.

The dirty way (I think you do not use a debugger) is to rewrite the following line

$paths = self::addIncludePath();


var_dump($paths = self::addIncludePath());

So you will see the paths where the Table-Class are stored.

3rd-party components tells Joomla where their own tables are located. Mostly like the following.


If you are searching for a 3rd-party component table, have a look in the /administrator/componentname/tables

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.