Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site Topic is solved

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
DerekE
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Dec 12, 2017 5:04 pm

Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by DerekE » Thu May 16, 2024 9:51 pm

First written in 2010, rewritten in 2016 for Joomla 3, and now rewritten again for Joomla 4/5 with all kinds of difficulties arising over a long development time, my component for viewing the history of concerts in our orchestra is at last functioning beautifully in my wamp64 environment on two different laptops, as is the process of restoring the localhost sites from Akeeba backups in both cases. My plan is simply to restore my local site to the live site. The great day for release to the main site arrived a couple of days ago, and I cannot get it to work.
I've checked all the obvious things - php version, MySQL version, possible corrupt backup (but same behaviour with backups from both laptops) and have run the Forum Post Assistant, which at first told me my online host's version of mySQL needed upgrading, which I have now fixed, and then the new mySQL version told me during the retoration that there were some foreign keys it didn't like which I therefore removed before creating a further new backup (and a FPA result without any problems reported).
1. My first restore gave the same error on both site and administrator: can't find component HCOCONCERTSCOMPONENT. Using exactly the same restore process in my wamp64 environments, no such error appears, and the autoload_psr4 file contains two more lines . So something is happening (in the live linux hosting environment as opposed to the Windows wamp64?). I've tried searching for incorrect use of forward and back spaces (confusion between namespaces and directory paths) but insofar as my limited understanding of namespaces I think everything looks OK.
I found that the autoload_psr4.php contained no mention of my component. When I edited it manually and added the two lines (for site and admin) which appear in my wamp64 versions, both site and admin start and function correctly until I access a a part of the site that uses my component. Front end (site) gives the error "500 - Layout default not found." although all tmpl default files are present and correct. The Administrator part gives the error An error has occurred. 0 count(): Argument #1 ($value) must be of type Countable|array, null given.
So
(a) is it possible that the restoration process is not registering my component and so re-creating an autoload file with out it being mentioned? And
(b) why would it work differently in the two different environments?
If I could re-create the problem in my wamp64 environment I could easily track it down, but it all works perfectly.
Any advice, please, on how to tackle the problem? I feel completely stymied.
Last edited by toivo on Thu May 16, 2024 10:20 pm, edited 1 time in total.
Reason: mod note: moved from 5.x General Questions

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17516
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by toivo » Thu May 16, 2024 10:19 pm

DerekE wrote: Thu May 16, 2024 9:51 pmis it possible that the restoration process is not registering my component and so re-creating an autoload file with out it being mentioned?
Delete the file administrator/cache/autoload_psr4.php and then access the website. The autoload file is created automatically when Joomla is accessed.

Does the .xml manifest file of your component declare the namespace, for example:

Code: Select all

	<namespace path="src">Derek\Component\HCOCONCERTSCOMPONENT</namespace>
Turn on the option Debug System in the Global Configuration. If the backend is inaccessible, write-enable the file configuration.php and make the following changes:

Code: Select all

	public $debug = true;
	public $error_reporting = 'maximum';
	public $log_everything = 1;
The detailed error message and the PHP call stack will now be displayed and also written into the log file administrator/logs/everything.php. Copy and paste the messages into your reply.
Toivo Talikka, Global Moderator

DerekE
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Dec 12, 2017 5:04 pm

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by DerekE » Fri May 17, 2024 4:25 pm

Toivo, many thanks for your very speedy, helpful and clear response.
I have been through each of the steps you suggest with the results as documented below. I very much hope the error messages will help you understand what's wrong. I regret I'm not familiar enough with it all to deduce an answer. I suspect that there's something in my component that is failing properly to register, but I'm still puzzled as to why it's absolutely fine in wamp64 environment.

1. Deleted autoload_psrt4.php:
result: site part: "0 - Class "J4xdemos\Component\HCOConcerts\Administrator\Extension\HCOConcertsComponent" not found
Admin part: joomla loads and everything seems to work fine until I try to access the HCOConcerts component, then the same error as on the site: An error has occurred.
0 Class "J4xdemos\Component\HCOConcerts\Administrator\Extension\HCOConcertsComponent" not found
At this stage, autoload_psr4 has NOT been regenerated- it is still absent.

2. XML namespace: <namespace path="src">J4xdemos\Component\HCOConcerts</namespace>
changed installation XML file from "HCOConcerts" to "HCOCONCERTSCOMPONENT" and installed the component by "upload package file". I need to understand a bit more about namespaces. I thought the namespade would be "HCOConcerts" not "HCOCONCERTSCOMPONENT".
result: XML file in the admin part of the component successfully showing on the site. in "Manage Extensions", the HCOConcerts component is showing as "enabled"
AND the autoload-psr4.php file has been regenerated
BUT the two HCOComponents lines had not been generated, and the same "...component not found" error message.
next, I uninstalled the component and then installed it again. No change.

3. Option Debug System turned on (Admin component working fine except for my component!) Logging "almost everything" turned on.
first, tried site. Looked in admin/logs/ and could find only error.php with irrelevant out of date entries - but short, so copied below..
#<?php die('Forbidden.'); ?>
#Date: 2024-05-14 22:16:11 UTC
#Software: Joomla! 5.1.0 Stable [ Kudumisha ] 16-April-2024 16:00 GMT

#Fields: datetime priority clientip category message
2024-05-14T22:16:11+00:00 INFO 45.56.96.210 joomlafailure Username and password do not match or you do not have an account yet.
2024-05-15T01:33:35+00:00 INFO 212.83.152.178 joomlafailure Username and password do not match or you do not have an account yet.
2024-05-15T05:41:55+00:00 INFO 46.22.51.150 joomlafailure Username and password do not match or you do not have an account yet.
2024-05-15T07:16:03+00:00 INFO 138.204.25.43 joomlafailure Username and password do not match or you do not have an account yet.
2024-05-17T04:03:49+00:00 INFO 51.255.62.9 tokenfailure Authentication failed
2024-05-17T04:06:38+00:00 INFO 51.255.62.1 tokenfailure Authentication failed
2024-05-17T04:15:31+00:00 INFO 51.255.62.2 tokenfailure Authentication failed
2024-05-17T04:38:40+00:00 INFO 51.255.62.6 tokenfailure Authentication failed

Looked in configuration.php and found public $debug = false; and public $error_reporting = 'none'; changed them to "true" and 'maximum';

File "everything.php" now created in logs, showing first the result with the site then the result with the admin part.

#
#<?php die('Forbidden.'); ?>
#Date: 2024-05-17 15:38:03 UTC
#Software: Joomla! 5.1.0 Stable [ Kudumisha ] 16-April-2024 16:00 GMT

#Fields: datetime priority clientip category message
2024-05-17T15:38:03+00:00 CRITICAL 86.170.63.88 error Uncaught Throwable of type Error thrown with message "Class "J4xdemos\Component\HCOConcerts\Administrator\Extension\HCOConcertsComponent" not found". Stack trace: #0 [ROOT]/libraries/vendor/joomla/di/src/ContainerResource.php(172): Joomla\DI\ServiceProviderInterface@anonymous->{closure}(Object(Joomla\DI\Container))
#1 [ROOT]/libraries/vendor/joomla/di/src/Container.php(95): Joomla\DI\ContainerResource->getInstance()
#2 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(177): Joomla\DI\Container->get('Joomla\\CMS\\Exte...')
#3 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(51): Joomla\CMS\Application\CMSApplication->loadExtension('Joomla\\CMS\\Exte...', 'hcoconcerts', '/home/hp3-linc2...')
#4 [ROOT]/libraries/src/Router/SiteRouter.php(565): Joomla\CMS\Application\CMSApplication->bootComponent('hcoconcerts')
#5 [ROOT]/libraries/src/Router/SiteRouter.php(400): Joomla\CMS\Router\SiteRouter->getComponentRouter('com_hcoconcerts')
#6 [ROOT]/libraries/src/Router/Router.php(407): Joomla\CMS\Router\SiteRouter->buildComponentPreprocess(Object(Joomla\CMS\Router\SiteRouter), Object(Joomla\CMS\Uri\Uri))
#7 [ROOT]/libraries/src/Router/Router.php(191): Joomla\CMS\Router\Router->processBuildRules(Object(Joomla\CMS\Uri\Uri), 'preprocess')
#8 [ROOT]/libraries/src/Router/Route.php(150): Joomla\CMS\Router\Router->build('index.php?Itemi...')
#9 [ROOT]/libraries/src/Router/Route.php(99): Joomla\CMS\Router\Route::link('site', 'index.php?Itemi...', true, 0, false)
#10 [ROOT]/modules/mod_menu/src/Helper/MenuHelper.php(154): Joomla\CMS\Router\Route::_('index.php?Itemi...', true, 0)
#11 [ROOT]/modules/mod_menu/mod_menu.php(16): Joomla\Module\Menu\Site\Helper\MenuHelper::getList(Object(Joomla\Registry\Registry))
#12 [ROOT]/libraries/src/Dispatcher/ModuleDispatcher.php(52): include('/home/hp3-linc2...')
#13 [ROOT]/libraries/src/Dispatcher/ModuleDispatcher.php(55): Joomla\CMS\Dispatcher\ModuleDispatcher::Joomla\CMS\Dispatcher\{closure}('/home/hp3-linc2...', NULL)
#14 [ROOT]/plugins/system/t3/includes/joomla4/ModuleHelper.php(227): Joomla\CMS\Dispatcher\ModuleDispatcher->dispatch()
#15 [ROOT]/plugins/system/t3/includes/joomla4/ModuleHelper.php(65): Joomla\CMS\Helper\ModuleHelper::renderRawModule(Object(stdClass), Object(Joomla\Registry\Registry), Array)
#16 [ROOT]/libraries/src/Document/Renderer/Html/ModuleRenderer.php(99): Joomla\CMS\Helper\ModuleHelper::renderModule(Object(stdClass), Array)
#17 [ROOT]/libraries/src/Document/Renderer/Html/ModulesRenderer.php(51): Joomla\CMS\Document\Renderer\Html\ModuleRenderer->render(Object(stdClass), Array, NULL)
#18 [ROOT]/libraries/src/Document/HtmlDocument.php(575): Joomla\CMS\Document\Renderer\Html\ModulesRenderer->render('off-canvas', Array, NULL)
#19 [ROOT]/libraries/src/Document/HtmlDocument.php(894): Joomla\CMS\Document\HtmlDocument->getBuffer('modules', 'off-canvas', Array)
#20 [ROOT]/libraries/src/Document/HtmlDocument.php(647): Joomla\CMS\Document\HtmlDocument->_renderTemplate()
#21 [ROOT]/libraries/src/Application/CMSApplication.php(1073): Joomla\CMS\Document\HtmlDocument->render(false, Array)
#22 [ROOT]/libraries/src/Application/SiteApplication.php(732): Joomla\CMS\Application\CMSApplication->render()
#23 [ROOT]/libraries/src/Application/CMSApplication.php(311): Joomla\CMS\Application\SiteApplication->render()
#24 [ROOT]/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#25 [ROOT]/index.php(32): require_once('/home/hp3-linc2...')
#26 {main}
2024-05-17T15:38:12+00:00 CRITICAL 86.170.63.88 error Uncaught Throwable of type Error thrown with message "Class "J4xdemos\Component\HCOConcerts\Administrator\Extension\HCOConcertsComponent" not found". Stack trace: #0 [ROOT]/libraries/vendor/joomla/di/src/ContainerResource.php(172): Joomla\DI\ServiceProviderInterface@anonymous->{closure}(Object(Joomla\DI\Container))
#1 [ROOT]/libraries/vendor/joomla/di/src/Container.php(95): Joomla\DI\ContainerResource->getInstance()
#2 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(177): Joomla\DI\Container->get('Joomla\\CMS\\Exte...')
#3 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(51): Joomla\CMS\Application\CMSApplication->loadExtension('Joomla\\CMS\\Exte...', 'hcoconcerts', '/home/hp3-linc2...')
#4 [ROOT]/libraries/src/Router/SiteRouter.php(565): Joomla\CMS\Application\CMSApplication->bootComponent('hcoconcerts')
#5 [ROOT]/libraries/src/Router/SiteRouter.php(400): Joomla\CMS\Router\SiteRouter->getComponentRouter('com_hcoconcerts')
#6 [ROOT]/libraries/src/Router/Router.php(407): Joomla\CMS\Router\SiteRouter->buildComponentPreprocess(Object(Joomla\CMS\Router\SiteRouter), Object(Joomla\CMS\Uri\Uri))
#7 [ROOT]/libraries/src/Router/Router.php(191): Joomla\CMS\Router\Router->processBuildRules(Object(Joomla\CMS\Uri\Uri), 'preprocess')
#8 [ROOT]/libraries/src/Router/Route.php(150): Joomla\CMS\Router\Router->build('index.php?Itemi...')
#9 [ROOT]/libraries/src/Router/Route.php(99): Joomla\CMS\Router\Route::link('site', 'index.php?Itemi...', true, 0, false)
#10 [ROOT]/modules/mod_menu/src/Helper/MenuHelper.php(154): Joomla\CMS\Router\Route::_('index.php?Itemi...', true, 0)
#11 [ROOT]/modules/mod_menu/mod_menu.php(16): Joomla\Module\Menu\Site\Helper\MenuHelper::getList(Object(Joomla\Registry\Registry))
#12 [ROOT]/libraries/src/Dispatcher/ModuleDispatcher.php(52): include('/home/hp3-linc2...')
#13 [ROOT]/libraries/src/Dispatcher/ModuleDispatcher.php(55): Joomla\CMS\Dispatcher\ModuleDispatcher::Joomla\CMS\Dispatcher\{closure}('/home/hp3-linc2...', NULL)
#14 [ROOT]/plugins/system/t3/includes/joomla4/ModuleHelper.php(227): Joomla\CMS\Dispatcher\ModuleDispatcher->dispatch()
#15 [ROOT]/plugins/system/t3/includes/joomla4/ModuleHelper.php(65): Joomla\CMS\Helper\ModuleHelper::renderRawModule(Object(stdClass), Object(Joomla\Registry\Registry), Array)
#16 [ROOT]/libraries/src/Document/Renderer/Html/ModuleRenderer.php(99): Joomla\CMS\Helper\ModuleHelper::renderModule(Object(stdClass), Array)
#17 [ROOT]/libraries/src/Document/Renderer/Html/ModulesRenderer.php(51): Joomla\CMS\Document\Renderer\Html\ModuleRenderer->render(Object(stdClass), Array, NULL)
#18 [ROOT]/libraries/src/Document/HtmlDocument.php(575): Joomla\CMS\Document\Renderer\Html\ModulesRenderer->render('off-canvas', Array, NULL)
#19 [ROOT]/libraries/src/Document/HtmlDocument.php(894): Joomla\CMS\Document\HtmlDocument->getBuffer('modules', 'off-canvas', Array)
#20 [ROOT]/libraries/src/Document/HtmlDocument.php(647): Joomla\CMS\Document\HtmlDocument->_renderTemplate()
#21 [ROOT]/libraries/src/Application/CMSApplication.php(1073): Joomla\CMS\Document\HtmlDocument->render(false, Array)
#22 [ROOT]/libraries/src/Application/SiteApplication.php(732): Joomla\CMS\Application\CMSApplication->render()
#23 [ROOT]/libraries/src/Application/CMSApplication.php(311): Joomla\CMS\Application\SiteApplication->render()
#24 [ROOT]/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#25 [ROOT]/index.php(32): require_once('/home/hp3-linc2...')
#26 {main}
2024-05-17T15:41:48+00:00 CRITICAL 20.172.46.206 error Uncaught Throwable of type Joomla\CMS\Router\Exception\RouteNotFoundException thrown with message "Page not found". Stack trace: #0 [ROOT]/libraries/src/Application/SiteApplication.php(754): Joomla\CMS\Router\Router->parse(Object(Joomla\CMS\Uri\Uri), true)
#1 [ROOT]/libraries/src/Application/SiteApplication.php(244): Joomla\CMS\Application\SiteApplication->route()
#2 [ROOT]/libraries/src/Application/CMSApplication.php(306): Joomla\CMS\Application\SiteApplication->doExecute()
#3 [ROOT]/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#4 [ROOT]/index.php(32): require_once('/home/hp3-linc2...')
#5 {main}
2024-05-17T15:41:49+00:00 CRITICAL 20.172.46.206 error Uncaught Throwable of type Joomla\CMS\Router\Exception\RouteNotFoundException thrown with message "Page not found". Stack trace: #0 [ROOT]/libraries/src/Application/SiteApplication.php(754): Joomla\CMS\Router\Router->parse(Object(Joomla\CMS\Uri\Uri), true)
#1 [ROOT]/libraries/src/Application/SiteApplication.php(244): Joomla\CMS\Application\SiteApplication->route()
#2 [ROOT]/libraries/src/Application/CMSApplication.php(306): Joomla\CMS\Application\SiteApplication->doExecute()
#3 [ROOT]/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#4 [ROOT]/index.php(32): require_once('/home/hp3-linc2...')
#5 {main}
2024-05-17T15:48:38+00:00 CRITICAL 185.156.72.30 error Uncaught Throwable of type Joomla\CMS\Router\Exception\RouteNotFoundException thrown with message "Page not found". Stack trace: #0 [ROOT]/libraries/src/Application/SiteApplication.php(754): Joomla\CMS\Router\Router->parse(Object(Joomla\CMS\Uri\Uri), true)
#1 [ROOT]/libraries/src/Application/SiteApplication.php(244): Joomla\CMS\Application\SiteApplication->route()
#2 [ROOT]/libraries/src/Application/CMSApplication.php(306): Joomla\CMS\Application\SiteApplication->doExecute()
#3 [ROOT]/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#4 [ROOT]/index.php(32): require_once('/home/hp3-linc2...')
#5 {main}
2024-05-17T15:50:14+00:00 CRITICAL 86.170.63.88 error Uncaught Throwable of type Error thrown with message "Class "J4xdemos\Component\HCOConcerts\Administrator\Extension\HCOConcertsComponent" not found". Stack trace: #0 [ROOT]/libraries/vendor/joomla/di/src/ContainerResource.php(172): Joomla\DI\ServiceProviderInterface@anonymous->{closure}(Object(Joomla\DI\Container))
#1 [ROOT]/libraries/vendor/joomla/di/src/Container.php(95): Joomla\DI\ContainerResource->getInstance()
#2 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(177): Joomla\DI\Container->get('Joomla\\CMS\\Exte...')
#3 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(51): Joomla\CMS\Application\CMSApplication->loadExtension('Joomla\\CMS\\Exte...', 'hcoconcerts', '/home/hp3-linc2...')
#4 [ROOT]/libraries/src/Router/SiteRouter.php(565): Joomla\CMS\Application\CMSApplication->bootComponent('hcoconcerts')
#5 [ROOT]/libraries/src/Router/SiteRouter.php(400): Joomla\CMS\Router\SiteRouter->getComponentRouter('com_hcoconcerts')
#6 [ROOT]/libraries/src/Router/Router.php(407): Joomla\CMS\Router\SiteRouter->buildComponentPreprocess(Object(Joomla\CMS\Router\SiteRouter), Object(Joomla\CMS\Uri\Uri))
#7 [ROOT]/libraries/src/Router/Router.php(191): Joomla\CMS\Router\Router->processBuildRules(Object(Joomla\CMS\Uri\Uri), 'preprocess')
#8 [ROOT]/libraries/src/Router/Route.php(150): Joomla\CMS\Router\Router->build('index.php?Itemi...')
#9 [ROOT]/libraries/src/Router/Route.php(99): Joomla\CMS\Router\Route::link('site', 'index.php?Itemi...', true, 0, false)
#10 [ROOT]/modules/mod_menu/src/Helper/MenuHelper.php(154): Joomla\CMS\Router\Route::_('index.php?Itemi...', true, 0)
#11 [ROOT]/modules/mod_menu/mod_menu.php(16): Joomla\Module\Menu\Site\Helper\MenuHelper::getList(Object(Joomla\Registry\Registry))
#12 [ROOT]/libraries/src/Dispatcher/ModuleDispatcher.php(52): include('/home/hp3-linc2...')
#13 [ROOT]/libraries/src/Dispatcher/ModuleDispatcher.php(55): Joomla\CMS\Dispatcher\ModuleDispatcher::Joomla\CMS\Dispatcher\{closure}('/home/hp3-linc2...', NULL)
#14 [ROOT]/plugins/system/t3/includes/joomla4/ModuleHelper.php(227): Joomla\CMS\Dispatcher\ModuleDispatcher->dispatch()
#15 [ROOT]/plugins/system/t3/includes/joomla4/ModuleHelper.php(65): Joomla\CMS\Helper\ModuleHelper::renderRawModule(Object(stdClass), Object(Joomla\Registry\Registry), Array)
#16 [ROOT]/libraries/src/Document/Renderer/Html/ModuleRenderer.php(99): Joomla\CMS\Helper\ModuleHelper::renderModule(Object(stdClass), Array)
#17 [ROOT]/libraries/src/Document/Renderer/Html/ModulesRenderer.php(51): Joomla\CMS\Document\Renderer\Html\ModuleRenderer->render(Object(stdClass), Array, NULL)
#18 [ROOT]/libraries/src/Document/HtmlDocument.php(575): Joomla\CMS\Document\Renderer\Html\ModulesRenderer->render('off-canvas', Array, NULL)
#19 [ROOT]/libraries/src/Document/HtmlDocument.php(894): Joomla\CMS\Document\HtmlDocument->getBuffer('modules', 'off-canvas', Array)
#20 [ROOT]/libraries/src/Document/HtmlDocument.php(647): Joomla\CMS\Document\HtmlDocument->_renderTemplate()
#21 [ROOT]/libraries/src/Application/CMSApplication.php(1073): Joomla\CMS\Document\HtmlDocument->render(false, Array)
#22 [ROOT]/libraries/src/Application/SiteApplication.php(732): Joomla\CMS\Application\CMSApplication->render()
#23 [ROOT]/libraries/src/Application/CMSApplication.php(311): Joomla\CMS\Application\SiteApplication->render()
#24 [ROOT]/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#25 [ROOT]/index.php(32): require_once('/home/hp3-linc2...')
#26 {main}
2024-05-17T15:51:46+00:00 CRITICAL 86.170.63.88 error Uncaught Throwable of type Error thrown with message "Class "J4xdemos\Component\HCOConcerts\Administrator\Extension\HCOConcertsComponent" not found". Stack trace: #0 [ROOT]/libraries/vendor/joomla/di/src/ContainerResource.php(172): Joomla\DI\ServiceProviderInterface@anonymous->{closure}(Object(Joomla\DI\Container))
#1 [ROOT]/libraries/vendor/joomla/di/src/Container.php(95): Joomla\DI\ContainerResource->getInstance()
#2 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(177): Joomla\DI\Container->get('Joomla\\CMS\\Exte...')
#3 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(51): Joomla\CMS\Application\CMSApplication->loadExtension('Joomla\\CMS\\Exte...', 'hcoconcerts', '/home/hp3-linc2...')
#4 [ROOT]/libraries/src/Router/SiteRouter.php(565): Joomla\CMS\Application\CMSApplication->bootComponent('hcoconcerts')
#5 [ROOT]/libraries/src/Router/SiteRouter.php(400): Joomla\CMS\Router\SiteRouter->getComponentRouter('com_hcoconcerts')
#6 [ROOT]/libraries/src/Router/Router.php(407): Joomla\CMS\Router\SiteRouter->buildComponentPreprocess(Object(Joomla\CMS\Router\SiteRouter), Object(Joomla\CMS\Uri\Uri))
#7 [ROOT]/libraries/src/Router/Router.php(191): Joomla\CMS\Router\Router->processBuildRules(Object(Joomla\CMS\Uri\Uri), 'preprocess')
#8 [ROOT]/libraries/src/Router/Route.php(150): Joomla\CMS\Router\Router->build('index.php?Itemi...')
#9 [ROOT]/libraries/src/Router/Route.php(99): Joomla\CMS\Router\Route::link('site', 'index.php?Itemi...', true, 0, false)
#10 [ROOT]/modules/mod_menu/src/Helper/MenuHelper.php(154): Joomla\CMS\Router\Route::_('index.php?Itemi...', true, 0)
#11 [ROOT]/modules/mod_menu/mod_menu.php(16): Joomla\Module\Menu\Site\Helper\MenuHelper::getList(Object(Joomla\Registry\Registry))
#12 [ROOT]/libraries/src/Dispatcher/ModuleDispatcher.php(52): include('/home/hp3-linc2...')
#13 [ROOT]/libraries/src/Dispatcher/ModuleDispatcher.php(55): Joomla\CMS\Dispatcher\ModuleDispatcher::Joomla\CMS\Dispatcher\{closure}('/home/hp3-linc2...', NULL)
#14 [ROOT]/plugins/system/t3/includes/joomla4/ModuleHelper.php(227): Joomla\CMS\Dispatcher\ModuleDispatcher->dispatch()
#15 [ROOT]/plugins/system/t3/includes/joomla4/ModuleHelper.php(65): Joomla\CMS\Helper\ModuleHelper::renderRawModule(Object(stdClass), Object(Joomla\Registry\Registry), Array)
#16 [ROOT]/libraries/src/Document/Renderer/Html/ModuleRenderer.php(99): Joomla\CMS\Helper\ModuleHelper::renderModule(Object(stdClass), Array)
#17 [ROOT]/libraries/src/Document/Renderer/Html/ModulesRenderer.php(51): Joomla\CMS\Document\Renderer\Html\ModuleRenderer->render(Object(stdClass), Array, NULL)
#18 [ROOT]/libraries/src/Document/HtmlDocument.php(575): Joomla\CMS\Document\Renderer\Html\ModulesRenderer->render('off-canvas', Array, NULL)
#19 [ROOT]/libraries/src/Document/HtmlDocument.php(894): Joomla\CMS\Document\HtmlDocument->getBuffer('modules', 'off-canvas', Array)
#20 [ROOT]/libraries/src/Document/HtmlDocument.php(647): Joomla\CMS\Document\HtmlDocument->_renderTemplate()
#21 [ROOT]/libraries/src/Application/CMSApplication.php(1073): Joomla\CMS\Document\HtmlDocument->render(false, Array)
#22 [ROOT]/libraries/src/Application/SiteApplication.php(732): Joomla\CMS\Application\CMSApplication->render()
#23 [ROOT]/libraries/src/Application/CMSApplication.php(311): Joomla\CMS\Application\SiteApplication->render()
#24 [ROOT]/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#25 [ROOT]/index.php(32): require_once('/home/hp3-linc2...')
#26 {main}
2024-05-17T15:52:02+00:00 CRITICAL 86.170.63.88 error Uncaught Throwable of type Error thrown with message "Class "J4xdemos\Component\HCOConcerts\Administrator\Extension\HCOConcertsComponent" not found". Stack trace: #0 [ROOT]/libraries/vendor/joomla/di/src/ContainerResource.php(172): Joomla\DI\ServiceProviderInterface@anonymous->{closure}(Object(Joomla\DI\Container))
#1 [ROOT]/libraries/vendor/joomla/di/src/Container.php(95): Joomla\DI\ContainerResource->getInstance()
#2 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(177): Joomla\DI\Container->get('Joomla\\CMS\\Exte...')
#3 [ROOT]/libraries/src/Extension/ExtensionManagerTrait.php(51): Joomla\CMS\Application\CMSApplication->loadExtension('Joomla\\CMS\\Exte...', 'hcoconcerts', '/home/hp3-linc2...')
#4 [ROOT]/libraries/src/Component/ComponentHelper.php(361): Joomla\CMS\Application\CMSApplication->bootComponent('hcoconcerts')
#5 [ROOT]/libraries/src/Application/AdministratorApplication.php(150): Joomla\CMS\Component\ComponentHelper::renderComponent('com_hcoconcerts')
#6 [ROOT]/libraries/src/Application/AdministratorApplication.php(195): Joomla\CMS\Application\AdministratorApplication->dispatch()
#7 [ROOT]/libraries/src/Application/CMSApplication.php(306): Joomla\CMS\Application\AdministratorApplication->doExecute()
#8 [ROOT]/administrator/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#9 [ROOT]/administrator/index.php(32): require_once('/home/hp3-linc2...')
#10 {main}

User avatar
ceford
Joomla! Hero
Joomla! Hero
Posts: 2794
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by ceford » Fri May 17, 2024 5:22 pm

Focus on this:

Code: Select all

 AND the autoload-psr4.php file has been regenerated
BUT the two HCOComponents lines had not been generated, and the same "...component not found" error message.
I suggest you review your namespace: J4xdemos\Component\HCOConcerts - perhaps create your own first part (J4xdemos came from one of my demos and I have since changed to Cefjdemos) and the third item could be simplified to Concerts. You have to make sure your file and folder names match case - that is a problem that could emerge in migrating from a Windows platform to a Linux platform, Make sure you manifest file is present in the root of your administrator component after installation.

robbiej
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Wed Apr 06, 2016 11:22 am

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by robbiej » Fri May 17, 2024 8:17 pm

Yes, it's almost certainly a problem with case in filenames. If it doesn't create your namespace in autoload-psr4.php then I think it can't find your manifest file. Ensure that the filename of your manifest file matches exactly (ie including case) the name of your component minus the com_ at the start.

Failing that, I think it's the plugins/extension/namespacemap plugin which creates the autoload-psr4.php file, so try stepping through that with a debugger.

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 12809
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by brian » Fri May 17, 2024 9:52 pm

To get a full explanation of how to use namespaces in your component I highly recommend reading https://www.dionysopoulos.me/book/conce ... namespaces
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

DerekE
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Dec 12, 2017 5:04 pm

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by DerekE » Sat May 18, 2024 4:29 pm

Thanks Robbiej and brian and again Toivo. All much appreciated. I think I've managed to confirm today that the issue is cases, but I've got myself into another mess as a result!
Actions taken and results:
1. Examined manifest file carefully. comparing with other Joomla ones, and found that I was not declaring my hcoconcerts.xml as a specific 'filename=..'. Uninstalled, reinstalled: result no change. Also wondered about the difference between "file" and "filename" declarations in Manifest, and changed existing ones from file to filename. No difference.
2. I then started tackling upper/lower case. I noted that in several Joomla components I looked at (e.g. com_content, com_contact) the directory structures at the top level are lower case (e.g. src, services, forms, tmpl, and then under src they are mixed case (e.g. Model, View, etc.) and the filenames under the mixed case are also mixed. But under tmpl, they are all lower case. I didn't understand why, but I changed mine to match. As per Toivo's suggestion I also replaced 'j4xdemos' with 'derek' throughout (88 occurrences in Admin and 20 on the site. It seemed worthwhile since if there were any legacy namespace issues they would surface in a hard error. My further notes for today include: Also discovered that DisplayController on, say, JoomlaContacts, uses lower case for default view definition, and also extends BaseController, not AdminController. So I changed both of these in HCOConcerts DisplayController. Also enabled display function, which was previously commented out.
I did not replace HCOConcerts by the simpler Concerts yet because it raises issues with other uses of the word "concert" in the component and I didn't want to change too much in one day.
Result: Good and bad news. The Autoload creation problem seems now to be resolved and I now have a working opening page of the site with functionality as normal except when I try to access my component. On the live site, the opening page simply re-displays without raising an error. But, where it was working previously in wamp64, it too simply redisplays the front page. Stepping through in my local debugger I find it is going through dozens of functions but the most relevant seems to be that it is searching for a Router and I have never created a Router so it's not finding it. Should I have created one? My DisplayController I thought was sufficient.
I'm hoping that reversing some of the changes above will revert to a working system, but not today! I'll post again when I have further input.

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by MarkRS » Sat May 18, 2024 4:46 pm

That sounds odd. You should just use the J! router, "use"ing it should be all that's needed.
It's a community, the more we all contribute, the better it will be.

User avatar
ceford
Joomla! Hero
Joomla! Hero
Posts: 2794
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by ceford » Sat May 18, 2024 4:56 pm

Just a small tip: everything in src is namespaced and must follow a naming convention. So for example we might expect to see in Controller: ConcertsController.php, which would be for the list of concerts, and ConcertController, which would be for an individual concert. This convention is known as Pascal Case. the tmpl folder items are not namespaced - so names are lower case.

robbiej
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Wed Apr 06, 2016 11:22 am

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by robbiej » Sat May 18, 2024 9:05 pm

Basically Joomla uses capital first letters for PHP classes (and for each segment of a fully-qualified classname), for the PHP files which contain PHP class definitions, and the subdirectories under the src folder (which contains the classes). This is because it follows the PHP PSR-4 recommendation https://www.php-fig.org/psr/psr-4/

Everywhere else it uses small letters at the start of filenames and folders.

There's more information (plus an explanatory video) on namespaces at https://manual.joomla.org/docs/general- ... amespaces/

Information on manifest files at https://docs.joomla.org/Manifest_files. You should use <filename> inside the <files> section. You can check the install has worked by examining the files in the target directory (eg components/com_HCOConcerts). However, when you install an update for a component Joomla just copies into the target directories the new files defined in the manifest. If there's an old file from a previous install in that directory, but it's not specified in the manifest file for the latest update, then Joomla won't delete it.

If you're using Joomla SEF URLs on your site then you'll need to define a router for your component, so I expect this will have been done for your Joomla 3 version - it should be in a file called router.php in your site development directory. Some information on how to go about it for Joomla 4 at https://manual.joomla.org/docs/general- ... s/routing/.

gws
Joomla! Champion
Joomla! Champion
Posts: 6056
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by gws » Sat May 18, 2024 9:25 pm

Very succinct robbiej. +1

DerekE
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Dec 12, 2017 5:04 pm

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by DerekE » Sun May 19, 2024 5:12 pm

Thanks to all for your wise inputs. I have made some progress. The component is now getting registered on the live site. Although I changed a great many upper/lower cases I think the most important one was the "name" tag in my manifest file. Previously it was "HCOConcerts". I changed it to com_hcoconcerts.
The site and admin are both working again smoothly in wamp64 following a hiccup when I made a mistake during my case changing, and I now have a live site that loads but when I try to access my component I have fatal errors both on the Site and the Administrator sections. I have made some progress in that in both cases the errors were previously "can't find component", but they are occurring in the same place according to the error log. HCOConcertsResults/HtmlView.php(58) Line 58 is the statement "return parent::display($tpl);"
Site error:
0 - Call to a member function get() on null
All Errors report log file:
2024-05-19T13:11:36+00:00 CRITICAL 86.170.63.88 error Uncaught Throwable of type Error thrown with message "Call to a member function get() on null". Stack trace: #0 [ROOT]/plugins/system/t3/includes/core/t3.php(533) : eval()'d code(416): include()
#1 [ROOT]/plugins/system/t3/includes/core/t3.php(533) : eval()'d code(204): Joomla\CMS\MVC\View\_JHtmlView->loadTemplate(NULL)
#2 [ROOT]/components/com_hcoconcerts/src/View/HCOConcertsResults/HtmlView.php(58): Joomla\CMS\MVC\View\_JHtmlView->display(NULL)
#3 [ROOT]/libraries/src/MVC/Controller/BaseController.php(697): derek\Component\HCOConcerts\Site\View\HCOConcertsResults\HtmlView->display()
#4 [ROOT]/components/com_hcoconcerts/src/Controller/DisplayController.php(278): Joomla\CMS\MVC\Controller\BaseController->display(false, false)
#5 [ROOT]/libraries/src/MVC/Controller/BaseController.php(730): derek\Component\HCOConcerts\Site\Controller\DisplayController->display()
#6 [ROOT]/libraries/src/Dispatcher/ComponentDispatcher.php(143): Joomla\CMS\MVC\Controller\BaseController->execute('display')
#7 [ROOT]/libraries/src/Component/ComponentHelper.php(361): Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch()
#8 [ROOT]/libraries/src/Application/SiteApplication.php(218): Joomla\CMS\Component\ComponentHelper::renderComponent('com_hcoconcerts')
#9 [ROOT]/libraries/src/Application/SiteApplication.php(261): Joomla\CMS\Application\SiteApplication->dispatch()
#10 [ROOT]/libraries/src/Application/CMSApplication.php(306): Joomla\CMS\Application\SiteApplication->doExecute()
#11 [ROOT]/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#12 [ROOT]/index.php(32): require_once('/home/hp3-linc2...')
#13 {main}

Administrator error:
An error has occurred.
0 count(): Argument #1 ($value) must be of type Countable|array, null given
2024-05-19T15:48:06+00:00 CRITICAL 86.170.63.88 error Uncaught Throwable of type TypeError thrown with message "count(): Argument #1 ($value) must be of type Countable|array, null given". Stack trace: #0 [ROOT]/administrator/components/com_hcoconcerts/src/View/HCOConcerts/HtmlView.php(54): count(NULL)
#1 [ROOT]/libraries/src/MVC/Controller/BaseController.php(697): derek\Component\HCOConcerts\Administrator\View\HCOConcerts\HtmlView->display()
#2 [ROOT]/libraries/src/MVC/Controller/BaseController.php(730): Joomla\CMS\MVC\Controller\BaseController->display()
#3 [ROOT]/libraries/src/Dispatcher/ComponentDispatcher.php(143): Joomla\CMS\MVC\Controller\BaseController->execute('display')
#4 [ROOT]/libraries/src/Component/ComponentHelper.php(361): Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch()
#5 [ROOT]/libraries/src/Application/AdministratorApplication.php(150): Joomla\CMS\Component\ComponentHelper::renderComponent('com_hcoconcerts')
#6 [ROOT]/libraries/src/Application/AdministratorApplication.php(195): Joomla\CMS\Application\AdministratorApplication->dispatch()
#7 [ROOT]/libraries/src/Application/CMSApplication.php(306): Joomla\CMS\Application\AdministratorApplication->doExecute()
#8 [ROOT]/administrator/includes/app.php(58): Joomla\CMS\Application\CMSApplication->execute()
#9 [ROOT]/administrator/index.php(32): require_once('/home/hp3-linc2...')
#10 {main}

View/HCOConcerts/HtmlView.php(54): line 54 is "if (count($errors = $this->get('Errors')))"

I've put break points in my wamp64 setup and examined all the values of variables at these particular points and can see no obvious case specific values that look as if they might need changing (but there were some when I had the "can't find component" error).

Really unsure where I'm going to go to go from here, but something might spring to mind overnight - it usually does, so I can spend yet another fruitless day!
Truly grateful for your assistance so far. If any thoughts spring to mind I'd love to hear them.

DerekE
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Dec 12, 2017 5:04 pm

Re: Autoload_psr4 or registration problem? My Joomla Component works fine with wamp64 localhost but fails on live site

Post by DerekE » Thu May 23, 2024 5:32 pm

Update: In case others have a similar problem I am recording here my analysis and solution.

The "error 0 - Call to a member function get() on null" was occurring when a line of code in my default template was trying to fetch a state value for the Joomla built-in sorting capability (e.g. list order and direction). I deduced that although in wamp64 Joomla happily loads the default model (which shows in wamp64 as "hcoconcertsmodel" in the registry with a value of "HCOConcertsModel" as the name), on the live site in linux it did not. I tried very hard indeed to find where I had specified the default model as all lower case, but could not find it. I suspected that on linux it might also not have loaded the data for my model too.
My solution was explictly to call an instance of the model in my view HtmlView file and again in the tmpl/default file, (using "$model = $app->bootComponent('com_hcoconcerts')->getMVCFactory()->createModel('HCOConcertsResults', 'Site');" and use $model->get and setState('xxxx') instead of $this->get and set (which was causing Joomla to call the model function by constructing what it thought was the model name). I now have the linux site working as perfectly with my component as it had in wamp64 over a week ago.


Post Reply

Return to “Joomla! 5.x Coding”