Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aktolman's avatar

Using Dom Document

I want to do some XML processing in my page logger middle ware. Basically turning an array in to XML.

When I run this code:

    if (!$this->domDoc = new domDocument($this->domVersion, $this->domEncoding ))
        throw new Exception(XML_DOMDOC_ERROR);

I am getting this in my error log:

HP Fatal error: Class 'App\domDocument' not found in /Applications/MAMP/htdocs/lara_AMRISV5/trunk/app/XML.php on line 40

I am probably being really stupid but the class exists when I test for it:

class_exists('DOMDocument');

Do I need to do something special to make it work? Am I being a fudge wit?

0 likes
5 replies
eslih's avatar

domDocument != DOMDocument, right?

aktolman's avatar

Sorry not had a chance to come back to this. Its not that - both should work DOM and dom...

It works outside of Laravel - just not within it... and being a noob I am at a loss...

aktolman's avatar

I can of course start hacking Laravel to try and find the issue... but presume it is something simple.

davorminchorov's avatar
Level 53

Did you import the full namespace at the top using the use keyword like:

use Path\To\DOMDocument;
aktolman's avatar

Hi Ruffles,

I just tried it with:

use DOMDocument

and that worked! I did try something with a path the other day but clearly I must have got it wrong... what a fudger...

Happy Days!

Please or to participate in this conversation.