How to Enable the WDDX Extension in PHP 7.4: Installation Guide

How to Enable the WDDX Extension in PHP 7.4: Installation Guide

Photo: pch.vector / Freepik.com
Photo: pch.vector / Freepik.com

The WDDX (Web Distributed Data eXchange) extension was deprecated and removed as of PHP 7.4. WDDX provides a neutral data interchange mechanism that allows the transfer of data between different programming languages, platforms, and systems. Despite its removal, it is still possible to install the WDDX extension manually in PHP 7.4. This guide will walk you through the process.

Step 1: Build and Install the WDDX PHP Extension

1. Download the WDDX Source Code

Run the following command to download the WDDX extension source code from GitHub:

wget https://github.com/php/pecl-text-wddx/archive/master.zip -O wddx.zip

2. Extract the Source Code

Unzip the downloaded file:

unzip wddx.zip
cd pecl-text-wddx-master

3. Prepare for Compilation

Use phpize to prepare the build environment. This tool is included with your PHP installation and prepares an extension for building. Execute:

phpize

4. Configure the Build Environment

Run the configure script to set up the extension build:

./configure

If your PHP installation is in a custom directory (e.g., /opt/alt/php/), specify the path to phpize and php-config:

/opt/alt/php/usr/bin/phpize
./configure --with-php-config=/opt/alt/php/usr/bin/php-config

5. Compile and Install the Extension

Build and install the WDDX extension by running:

make
make install

Step 2: Enable the WDDX Extension

1. Open the PHP configuration file (php.ini) for editing.

The location of php.ini depends on your system setup (common locations include /etc/php.ini or /etc/php/7.4/apache2/php.ini).

2. Add the following line to enable the WDDX extension:

extension=wddx.so

3. Restart the PHP service.

Depending on your setup, restart the appropriate service:

For Apache:

systemctl restart apache2

For PHP-FPM:

systemctl restart php-fpm

Step 3: Verify the Installation

To confirm that the WDDX extension is installed and enabled, run the following command:

php -m | grep wddx

If the installation was successful, the output should include wddx:

[root@hostname]# php -m | grep wddx
wddx

Alternatively, you can check the PHP Info page:

1. Create a PHP file (e.g., info.php) in your web server’s root directory:

<?php phpinfo(); ?>

2. Open the file in your browser and search for “wddx” to confirm the extension is loaded.

That’s It!

By following these steps, you can successfully enable the deprecated WDDX extension in PHP 7.4 for continued use in your projects.