Advertisement

Joomla 5 cannot find standard PHP class Topic is solved

Need help upgrading your Joomla! website or converting to Joomla! 5.x?

Moderator: 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
kalinma
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Wed Jul 22, 2009 2:59 pm

Joomla 5 cannot find standard PHP class

Post by kalinma » Tue Sep 10, 2024 3:41 pm

I am upgrading an application to Joomla 5 and everything was fine until I started using namespaces. Now my component cannot find DOMDocument, a standard PHP class. It is trying to find the PHP class within my namespace. The error displayed is:

Class "My/Namespace/Path/Here/DOMDocument" not found

DOMDocument has been part of PHP since version 5. This is on my localhost with XAMPP on Windows 10. I'm running PHP 8.3.10, MariaDB 10.4.32 and Joomla 5.1.4. I have restarted apache and mysql several times with no success. How is it my component cannot find a standard PHP class and expects to find it within my namespace?

Advertisement
SharkyKZ
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3062
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Joomla 5 cannot find standard PHP class

Post by SharkyKZ » Tue Sep 10, 2024 4:25 pm

Prefix the class with a backslash or add "use" statement to import the class https://www.php.net/manual/en/language. ... orting.php

kalinma
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Wed Jul 22, 2009 2:59 pm

Re: Joomla 5 cannot find standard PHP class

Post by kalinma » Tue Sep 10, 2024 4:35 pm

Thanks, Sharky. The backslash worked.

Advertisement

Post Reply

Return to “Migrating and Upgrading to Joomla! 5.x”