Search code examples
phphomebrewphp-extensionphp-7.2pdflib

Installing PHP 7.2 extension pdflib, module error


I am trying to install pdflib on PHP 7.2 which I already had installed before. Somehow I restructured my PHP Installation with Homebrew a while ago. Before that restructure I had my extensions in /usr/local/etc/php/7.2/extensions. I just needed to reference my .so Files in php.ini and everything had been working just fine.

After the restructure I used pecl to install new extensions. Now I have my extensions in usr/local/lib/php/pecl/20170718 which is also referenced in my php.ini as extension_dir. But if I put the pdflib.so inside this directory and register it in php.ini I get the following error:

Warning: PHP Startup: PDFlib: Unable to initialize module
Module compiled with module API=20160303
PHP    compiled with module API=20170718
These options need to match`Warning: PHP Startup: PDFlib: Unable to 
initialize module

How can I solve this or is there a way to roll back to the old configuration?


Solution

  • Module compiled with module API=20160303
    PHP    compiled with module API=20170718
    

    this message indicate, that a PDFlib DSO is loaded, which was build for an older PHP (PHP 7.1).

    I see two possible problems:

    • a different extension is loaded by accident. For example due to different names. (php_pdflib.so vs pdf.so)
    • your PECL build go wrong, and it was build the extension against the old PHP 7.1.

    I would recommend

    • check your php.ini and remove all extensions with pdf
    • download the latest PDFlib 9.1.2 from the website and unpack the package
    • copy the correct DSO (php_pdflib.so) to your extension_dir
    • add now extension=php_pdflib.so to your php.ini

    hope that helps, Rainer