Autoload file not updated on new component install Topic is solved

For Joomla! 4.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
jjbongio
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Mon Dec 16, 2013 2:29 pm

Autoload file not updated on new component install

Post by jjbongio » Mon Dec 04, 2023 6:29 pm

Using v4.4.1 and seeing a new problem. If I install a new component (i.e. one that doesn't already exist), the autoload_psr4.php is not updated. When I access a component view (in the admin menu), I get the error Invalid controller class: display
If I delete autoload_psr4.php, it is recreated correctly, and the problem goes away.

I have reproduced the problem using the simple hello world component described here
https://docs.joomla.org/J4.x:Developing ... oworld.xml

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

Re: Autoload file not updated on new component install

Post by toivo » Wed Dec 06, 2023 8:21 am

The update of the file administrator/cache/autoload_psr4.php works all right in Joomla 4 and Joomla 5 during the installation of a new component, as long as the namespace definition and everything else is all right.

I have not tested the example from Joomla tutorial you are using. The following line in the .xml manifest stands out:

Code: Select all

    <namespace path="src/">JohnSmith\Component\HelloWorld</namespace>
Remove the slash following src and try then:

Code: Select all

[code]    <namespace path="src">JohnSmith\Component\HelloWorld</namespace>
Did you copy and paste the code from the tutorial or type it all in? Are you testing in a remote Linux site or on a localhost under Windows? Linux is a case sensitive environment, whereas Windows is not.
Toivo Talikka, Global Moderator

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2846
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Autoload file not updated on new component install

Post by SharkyKZ » Wed Dec 06, 2023 8:37 am

Make sure that "Extension - Namespace Updater" plugin is enabled.

jjbongio
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Mon Dec 16, 2013 2:29 pm

Re: Autoload file not updated on new component install

Post by jjbongio » Wed Dec 06, 2023 6:52 pm

I copied and pasted from the tutorial.

SharkyKZ, that was the problem, thanks. Somehow the plugin was disabled. Enabling it fix it.

CharlieBigley
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Sep 03, 2020 10:23 am

Re: Autoload file not updated on new component install

Post by CharlieBigley » Wed Jan 24, 2024 7:34 am

Another thing to remember, the first time you install the component, the "method" attribute of the <extension> tag in the manifest file must be "install" not "upgrade". Only when the component has been successfully installed can you "upgrade" it.

The implication of this when developing a component is that if you change you component, you may need to offer two installation mechanisms, one for existing customers/installations and a slightly different one for upgrades to an existing customer/installation.

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

Re: Autoload file not updated on new component install

Post by toivo » Fri Feb 09, 2024 10:35 am

CharlieBigley wrote:
Wed Jan 24, 2024 7:34 am
the first time you install the component, the "method" attribute of the <extension> tag in the manifest file must be "install" not "upgrade".
That is not how the <extension> tags of manifest files work. An extension marked as 'upgrade' can be installed even if the website does not have an earlier version.

On the contrary, if the "method" attribute of the manifest file is 'install' and the extension happens to exist, the Joomla installer gracefully stops, as mentioned in the Joomla document Manifest Files - Root Element.

manifest-install-method.png
You do not have the required permissions to view the files attached to this post.
Toivo Talikka, Global Moderator


Post Reply

Return to “Joomla! 4.x Coding”