Trying to get gnupg to work on a PHP 8.1 installation.
This seems to work in the Dockerfile I'm using:

RUN apt-get install -y libgpgme11-dev && pecl install gnupg

When I attach to the running web server, I can do:

# pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
gnupg   1.5.1   stable

But when I run the test for the one functionality that uses it, I get:

Fatal error: Uncaught Error: Class "gnupg" not found in /var/www/html/.../decryptparams.php:9

The offending code:

	function intercept(Context $context, ActionInvocation $invocation) {
		if ($context->identity->offsetGet('decryptParams', false)) {
			putenv('GNUPGHOME=/var/www/.gnupg');
			$gpg = new gnupg(); // <--- line 9

Am I missing a step that actually makes that extension usable/accessible, or could it be an include path thing, or...?

    Okay, I added a line in my Dockerfile to add extension=gnupg to the php.ini file, and that seemed to sort things out. I'm guessing there may be a more "correct" way, but I'm fine with this -- it's kind of an edge case that I don't think is actually being used any more, but I figured I'd fix it just in case. 🙂

      NogDog changed the title to PECL gnupg on PHP 8 (solved, I think).
        19 days later

        That sounds like a poorly written APT package. Editing the PHP.INI file to enable an extension works, but there's also phpenmod, as described here.

          Write a Reply...