Search code examples
phpphp-extensionpecl

Using xdiff functions in PHP


I am running PHP7 on my CentOS server, and I understand that the xdiff functions need the addition of a suitable PECL package.

I have run the following:

pecl install xdiff-2.0.1

In my php.ini file I have tried:

extension=xdiff.so

and

extension=/usr/lib64/php/modules/xdiff.so

in both cases, I get an error when I try to use xdiff_string_patch():

Call to undefined function xdiff_string_patch()

I presume that I am missing a step, but I have no idea. What do I need to do to get this working?


Solution

  • So, it seems that the extension library does exist and that you are using the right php.ini, however, the following warning pops up at running a PHP script:

    PHP Warning: PHP Startup: xdiff: Unable to initialize module Module compiled with module API=20151012 PHP compiled with module API=20170718 These options need to match in Unknown on line 0 /etc/php.d/40-xdiff.ini
    

    This warning suggests a version mismatch between the module and your PHP binary.

    To fix this, uninstall the PECL extension and upgrade your php-dev binaries to the version that is appropriate for your PHP version, this depends on your distribution.

    Also, it might be useful to update your PECL settings, depending on your configuration (php -i):

    (sudo) pecl config-set php_ini /etc/php.ini 
    (sudo) pecl config-set php_bin $(which php)