All,
I'm trying to develop my first Joomla component and I'm following the MVC tutorial at here.
But I could not progress much because I'm getting the following error.
#0 Invalid controller class: AbcController
I've enabled the debug trace and it's giving an error at the following line:
JControllerLegacy::getInstance()
Needless to mention, I have already spent quite some time searching for a solution but could not find any solution.
I'm working on:
OS: Windows 8.1
PHP version: 5.5.6
MySQL version: 5.6.16
Joomla version: Joomla! 3.3.1 Stable
I followed following steps:
Created an entry in extensions table.
INSERT INTO
abc
.abc_extensions
(extension_id
,name
,type
,element
,folder
,client_id
,enabled
,access
,protected
,manifest_cache
,params
,custom_data
,system_data
,checked_out
,checked_out_time
,ordering
,state
) VALUES (701, 'com_abc', 'component', 'com_abc', '', 1, 1, 1, 0, '{"name":"com_abc","type":"component","creationDate":"July 2014","author":"ABC Project","copyright":"(C) 2005 - 2014 Open Source Matters. All rights reserved.\n\t","authorEmail":"[email protected]","authorUrl":"www.abc.org","version":"1.0.0","description":"COM_ABC_DESCRIPTION","group":""}', '{"enabled":"0","show_date":"1"}', '', '', 0, '0000-00-00 00:00:00', 0, 0);The main component code mysite/component/com_abc/abc.php is;
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import joomla controller library jimport('joomla.application.component.controller'); // Get an instance of the controller prefixed by HelloWorld $controller = JControllerLegacy::getInstance('Abc'); // Perform the Request task $input = JFactory::getApplication()->input; $controller->execute($input->getCmd('task')); // Redirect if set by the controller $controller->redirect();
The controller code mysite/component/com_abc/controller.php is:
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import Joomla controller library jimport('joomla.application.component.controller'); /** * Hello World Component Controller */ class AbcController extends JControllerLegacy { }
The view file mysite/component/com_abc/views/main/view.html.php contains:
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import Joomla view library jimport('joomla.application.component.view'); /** * HTML View class for the HelloWorld Component */ class AbcViewMain extends JViewLegacy { // Overwriting JView display method function display($tpl = null) { // Assign data to the view $this->msg = 'Hello World'; // Display the view parent::display($tpl); } }
The template file mysite/component/com_abc/views/main/tmpl/default.php contains:
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); ?> <h1><?php echo $this->msg; ?></h1>
The view is called using index.php?option=com_abc&view=main
Appreciate if you could help me in resolving the issue.
Many thanks.