Background
One of the components in a web application solution we’re developing uses xmlrpc_encode_request() in PHP.
It was executing fine in most of our systems systems – development and multiple test servers – but while trying to run it for the first time in my development environment I received the following error:
Fatal error: Uncaught Error: Call to undefined function xmlrpc_encode_request()
So off to Google I go and, find a few answers, have a couple of mis-starts, then finally get it working.
Solution
The solution was very simple.
- Install the xmlrpc extension.
sudo apt-get install php-xmlrpc- Restart Apache web server
sudo service apache2 restart
As a sanity check, create a PHP file (e.g. info.php) and add the following:
<?php echo 'XMLRPC is ', extension_loaded('xmlrpc') ? 'loaded' : 'not loaded'; ?>
When you run the file it you should see “XMLRPC is loaded” if all is good.
If you’re still having trouble, try updating your php.ini file to include:
extension=xmlrpc.so;
and/or
extension=php_xmlrpc.so;
Unfortunately, if you still have trouble then I apologise and suggest hitting Google/Bing/DuckDuckGo/StackOverflow again and playing around with search terms that meet your specific Linux/OS/PHP versions.
More Background
I started with a search for “Fatal error: Uncaught Error: Call to undefined function xmlrpc_encode_request” then “lamp Fatal error: Uncaught Error: Call to undefined function xmlrpc_encode_request”, and had these results:
- https://stackoverflow.com/questions/24473366/issue-with-wordpress-xmlrpc
- https://www.khattam.info/solved-fatal-error-call-to-undefined-function-xmlrpc_encode_request-in-pathtoaphpfile-on-line-x-2010-09-25.html
- https://stackoverflow.com/questions/4031648/xmlrpc-not-working-on-localhost
But they were aimed at PHP 5.x (by the way, if you’re still on PHP 5.x then update! It’s no longer supported and you’re now a security risk).
Then I refined my search to “apt-get php 7.2 xmlrpc” and had:
And I found the helpful suggestion for the info PHP file (you could also just run phpinfo(); in a file) at: