Symfony ubuntu: Attempted to load class "DOMDocument" from the global namespace

In most of the cases, the PHP xml extension is not included on Ubuntu, which throw an exception with the usage of classes like XmlFileLoader or parseFileToDOM or XmlUtils that instantiate the DOMDocument class.

Solution

To solve this issue execute the following command in a terminal:

sudo apt-get install php-xml

Then restart apache (in case it's active) using:

sudo service apache2 restart

and continue with what you were doing.

Still without work?

If the installation of the php-xml extension doesn't work, then proceed to install php-mbstring and php-curl using:

sudo apt-get install php-curl
sudo apt-get install php-mbstring
sudo apt-get update

This should fix the problem, happy coding !

Become a more social person