Class 'SimpleXMLElement' not found on puphpet PHP 5.6

Class 'SimpleXMLElement' not found on puphpet PHP 5.6

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Class 'SimpleXMLElement' not found on puphpet PHP 5.6

Encountering a Fatal error: Class 'SimpleXMLElement' not found is frustrating, especially when your application works perfectly in production or on a local WampServer setup with the same PHP version (5.6.2). It feels like a configuration oversight, but often it stems from how the PHP interpreter was compiled or what modules are actually loaded at runtime.

The error message points to NavLog.php line 29. Since you confirmed no namespaces are involved and phpinfo() shows the SimpleXML extension is listed under "SimpleXML," the module isn't missing from the build entirely. However, the presence of the section header in phpinfo() does not guarantee that the class is being loaded into the current process's memory space.

The Hidden Culprit: OPcache

In many modern PHP installations, particularly those deployed via Puppet or managed container environments, the default setting for opcache.enable might be disabled by default, or conversely, there could be a conflict preventing extensions from initializing correctly if opcache.revalidate_freq is set too aggressively during boot. More commonly in this specific scenario involving legacy code on newer systems: the extension is loaded, but the opcode cache is preventing the class definition from being recognized immediately.

Wait, let's correct that logic. If SimpleXML appears in phpinfo(), the extension is loaded. The real issue usually lies in how the PHP binary was compiled against OpenSSL or other libraries, which can sometimes cause extensions to fail initialization silently if dependencies are mismatched between your new VM and your old machine.

However, there is a more specific and common cause for this exact error on fresh Puppet installations: the simplexml extension is not included in the php.ini include_path or is missing from the loaded extensions list despite appearing in info.

Check your active php.ini. Run the following command to see exactly what is loaded:

php -m | grep simplexml

If this returns nothing, but phpinfo() shows the section, you are likely running two different PHP binaries. One might be CLI (php) and the other CGI/FPM (/usr/bin/php-fpm). Often, the FPM configuration (e.g., /etc/php/5.6/fpm/php.ini) lacks the line:

extension=php_simplexml.dll

Or on Debian/Ubuntu based systems where it is a shared object:

extension=xml.so

Ensure that xml.so is loaded, as SimpleXML depends on the underlying libxml library. If xml.so is missing, SimpleXMLElement will throw a fatal error even if the extension header exists in the info page (which sometimes renders stale cached data).

Verifying the Binary Context

Since your project works on WampServer and production but fails on Puphpet, compare the paths:

# On your new machine
php -i | grep "Loaded From"
# Compare this with the path of your web server's PHP process
ps aux | grep php-fpm

If the CLI php and the php-fpm binary are different versions (e.g., 5.6.2 vs 5.6.30), extension availability can differ significantly. A newer PHP build might have dropped support for a specific legacy module version or changed default compilation flags.

The Solution

  1. Force the Extension Load: Edit the active php.ini used by your web server (not CLI). Add:

    extension=xml.so
    extension=mbstring.so
    

    Ensure no whitespace precedes these lines, and verify that zend_extension directives aren't blocking it.

  2. Clear OPCache: If you have opcache.enable=1, restart your PHP-FPM service to ensure the cache is flushed. Sometimes, a stale opcode cache holds onto an old state where the class was considered "undefined" before the extension reloaded.

    service php5.6-fpm restart
    # Or using systemd
    systemctl restart php5.6-fpm
    
  3. Check for Typos in Includes: Ensure you aren't accidentally calling require_once or include a file that expects the class to be defined before the extension is loaded, though this is rare for built-in extensions.

Why This Happens on Puppet

Puppet automates configurations, but it doesn't always default to the most recent PHP packages available in your repository. If your old machine had a specific patch applied or a different php5-dev package version, the new system might be missing a dependency required to compile the simplexml module into a shared object.

If adding the extension line to php.ini yields no change and php -m still shows nothing, you may need to reinstall the PHP module:

apt-get install php5.6-xml
# or
yum install php-simplexml

Once the package is installed, verify that the .so file exists in your extension_dir (usually /usr/lib/php/20131226 for PHP 5.6). If the file exists but isn't loaded, double-check php.ini for syntax errors or conflicting zend_extension lines that might be crashing the initialization phase before simplexml loads.

By aligning your FPM configuration with the CLI environment and ensuring the underlying XML library is explicitly loaded, you resolve the discrepancy between your old WampServer setup and your new Puphpet deployment without needing to rewrite your application logic.

Our network