How to enable xmlwriter after PHP having been compiled?
If you are encountering a missing ext/xmlwriter extension while deploying an application like phpMyFAQ on Fedora or similar Linux distributions, the immediate instinct is often to check your configuration files. The PHP manual explicitly states that this extension is enabled by default and can only be disabled during the initial compilation phase via the --disable-xmlwriter flag. This phrasing suggests that once PHP is installed, you cannot simply flip a switch in php.ini or drop in a shared object file to turn it on.
However, declaring an extension "disabled" at compile time does not always result in a binary state where the code is permanently erased from the build artifacts. It often depends on whether the extension was included in the core PHP installation or treated as a separate module that could be loaded dynamically. If your PHP build treats xmlwriter as a dynamic library rather than embedded code, there is a viable path to enabling it without triggering a full recompile of the entire interpreter.
To determine if you can enable the extension post-installation, you must first inspect the current state of your PHP binary. Run the following command to list all loaded extensions:
php -m | grep xmlwriter
If this returns nothing, the extension is definitely absent. Next, check for the existence of a corresponding shared object file that might have been built but not loaded. Look in the standard extensions directory, usually found at /usr/lib64/php/modules/ on 64-bit Fedora systems:
ls /usr/lib64/php/modules/xmlwriter.so
If xmlwriter.so exists, your PHP was compiled with support for the extension as a loadable module. In this scenario, you do not need to touch the build process. You can simply enable the extension by adding a line to your active configuration file:
extension=xmlwriter
Locate your php.ini file using php --ini and add the directive there, or create a new file named 10-xmlwriter.ini in the directory pointed to by php_ini_scanned_dirs. Once saved, restart your web server or CLI to pick up the change. This approach works because the library code was compiled into the system, but the loader logic was configured to ignore it unless explicitly requested.
If the .so file does not exist, the situation is more rigid. The extension was likely stripped from the final binary during the compilation process using the --disable-xmlwriter flag, or the build system failed to generate the module at all. In this specific case, editing configuration files will yield no results. The PHP runtime literally does not know how to load the extension because the object file is missing.
Attempting to force-enable it in php.ini when the binary lacks the necessary symbols will result in a fatal error upon startup or simply be ignored if the loader cannot find the file. To resolve this without recompiling PHP from source, you must rebuild the specific module. This involves uninstalling the current PHP package, downloading the source code matching your exact version (e.g., 5.4.x for older Fedora releases), and running make install with the default settings, ensuring --disable-xmlwriter is omitted.
Alternatively, if you are using a package manager like yum, you might find that the extension is available as a separate dependency or that your current installation is an older snapshot where the flag was accidentally applied. Checking for updates or verifying the specific build arguments used by your distribution's RPM spec file can clarify why the module is missing. If recompiling PHP from source becomes unavoidable, ensure you explicitly enable all standard extensions to avoid similar gaps in functionality later.
While most modern distributions bundle xmlwriter as a core component that cannot be disabled, legacy systems or custom-built environments often treat it as an optional module. Understanding whether your PHP was built with the extension statically linked or dynamically loadable is the key to deciding between a simple config edit and a source rebuild.