iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
💨

Installing PECL::Runkit7 on Ubuntu 20.04 for StaticMock

に公開

The legendary PECL, once a titan of its era, returns
------------------- ↓ Preface begins here ↓-------------------

What was phpize again?

Digging into distant memories,
Ah, right, that thing existed.

I imagine most people have never had to compile PHP themselves.
( ̄ー ̄) "Back in the day..."
I'm not here to reminisce about some long-lost utopia, though.

I needed to install StaticMock on the latest Ubuntu, and was told I needed Runkit7 for it.
Apparently, it's more powerful than the Mockery module, and requires PECL::Runkit7.

('ω') What's that, again?

It's been a while since I've looked at a PECL page,
I'm surprised it's still alive.
What's more, it seems it's still being maintained, with the latest update on 2020/10/08.
(That's amazing)

Anyway, my local Ubuntu doesn't have PECL,
nor does it have things like phpize installed.

Let's give it a try.

ヾ(・ω<)ノ" 三三三● ⅱⅲ Rolling along♪

------------------- ↓ Main topic begins here ↓-------------------

Prerequisites

Assuming PHP is running via the command line.

sudo apt install php-cli

Install PHP development tools

If you reach this point, you're almost done.
Install php-dev, which contains the development tools for the PHP package mentioned above.
Also, install the pecl command while you're at it.

sudo apt install php-dev php-pear
phpize -v
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902

Install PECL::Runkit7

Once you've made it this far, the pecl command is efficient enough to handle the rest automatically.

sudo pecl install runkit7-alpha

Modify php.ini

When you install PHP via apt, it's managed under /etc/php/x.x/mods-available, but you can also add it directly to php.ini.

Add the following line:

extension=runkit7.so

Verify installation

Running phpinfo should show information related to runkit.

php -i | grep -i runkit
runkit7
runkit7 support => enabled
runkit.internal_override => Off => Off
runkit.superglobal => no value => no value
PWD => /home/dozo/tmp/runkit7-4.0.0a2
$_SERVER['PWD'] => /home/dozo/tmp/runkit7-4.0.0a2

Discussion