Problem Trying "Hello World" Component

554 views
Skip to first unread message

Mark Dexter

unread,
Jun 11, 2022, 1:17:13 PM6/11/22
to Joomla! General Development
I'm trying to follow the J4.X Developing an MVC Component tutorial (which evidently is still under construction). This is available at https://docs.joomla.org/J4.x:Developing_an_MVC_Component/.

I can do step 2 (admin view) but when I try to do step 3 (site view) I get the error message "Invalid controller class: display".

For reasons I don't understand, the DisplayController class (in components/com_helloworld/src/Controller folder) doesn't seem to get loaded.

I checked the administrator/cache/autoload_ps4.php file and there are two lines in there as follows:

    'JohnSmith\\Component\\HelloWorld\\Administrator\\' => [JPATH_ADMINISTRATOR . '/components/com_helloworld/src'],
    'JohnSmith\\Component\\HelloWorld\\Site\\' => [JPATH_SITE . '/components/com_helloworld/src'],

So I think this is OK.

Any ideas about how to troubleshoot would be much appreciated. Thanks!



MarkRS

unread,
Jun 11, 2022, 1:35:57 PM6/11/22
to Joomla! General Development
My favourite troubleshooting, and in fact development, "trick" is to develop with an IDE, I use Netbeans for php code, and use a mixture of single stepping and setting breakpoints to see what'a actually happening where.

Glenn Arkell

unread,
Jun 11, 2022, 4:53:03 PM6/11/22
to Joomla! General Development
Just checked my DisplayController and I have a construct function as well as the display.
    public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
    {
        parent::__construct($config, $factory, $app, $input);
    }

Is this what is missing perhaps?  Cheers.

MarkRS

unread,
Jun 12, 2022, 3:44:40 AM6/12/22
to Joomla! General Development
If that's all that's in it, I don't suppose that's what's missing because, as it does nothing but pass its parameters on to its parent, it's not required at all.

Hannes Papenberg

unread,
Jun 12, 2022, 3:47:30 AM6/12/22
to Joomla! General Development
Do you have the correct namespace used in the file? Check if the file is included by placing some debug code outside of the class. Is the capitalization of the filename correct?

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/joomla-dev-general/e6ba298e-3455-432f-a880-890cbbe48c0an%40googlegroups.com.

Cliff

unread,
Jun 14, 2022, 8:24:07 AM6/14/22
to Joomla! General Development
One thing I notice is that the tutorial does not include mention of administrator/com_helloworld/src/Extension/HelloworldComponent.php (see any other component for an example).

This tutorial was prepared in December 2020 so I guess is out of date. You could look at https://github.com/ceford/j4xdemos-com-bpsrc which is something I put together as part of another tutorial. You could also look at https://github.com/ceford/j4xdemos-com-countrybase which is the code for that other tutorial. Each can be installed and picked apart to see how they work. And  https://docs.joomla.org/J4.x:Links:_MVC_Anatomy is that other tutorial.

Fernando Goncalves

unread,
Jun 17, 2022, 4:12:27 PM6/17/22
to joomla-de...@googlegroups.com, dexter...@gmail.com
Hi

See if one this variants hellp you.

helloworld04.zip
helloworld03.zip
Reply all
Reply to author
Forward
0 new messages