Putting in PHP extensions historically concerned demanding situations like discovering precompiled binaries, the usage of OS package deal managers, or manually compiling from supply. Those strategies might be inconsistent throughout platforms and required other instructions, making the method complicated and liable to mistakes.

PECL, whilst useful, feels antiquated. It’s now not as simple to place your extension in PHP as it’s with Composer. PIE is an initiative from the PHP Basis to resolve this via treating extensions as Composer applications. It simplifies the method, provides higher cross-platform consistency, and guarantees more uncomplicated updates and control for PHP extensions.

Must haves

Earlier than we start, be sure to have PHP 8.1 or more recent to run PIE. On the other hand, PIE can set up extensions for any put in PHP model. To test the PHP model in your laptop, you’ll be able to run: php -v

Checking PHP version using php -v command

Set up

To put in the PHP Installer for Extensions (PIE), you’ll be able to observe those steps:

1. Obtain the PHAR package deal

First, you wish to have to obtain the pie.phar report from the reliable repository or web page. That is the principle report wanted to make use of PIE.

2. PHAR set up

Transfer pie.phar into your laptop’s PATH, corresponding to /usr/native/bin/, so you’ll be able to run it from any place. You’ll be able to rename it for comfort, for instance:

mv pie.phar /usr/native/bin/pie

On Home windows, you’ll be able to transfer it to C:Program Information or another listing on your PATH. On the other hand, I like to recommend the usage of Composer and its CLI with the Home windows Subsystem for Linux (WSL) for a greater revel in.

3. Make it executable

On non-Home windows machines, you wish to have to switch the permissions to make it executable.

chmod +x /usr/native/bin/pie

That’s it. You’ll be able to check out working pie on your terminal to look if it’s put in as it should be.

Checking PIE version after installation

We will now use PIE to put in PHP extensions very easily the usage of the pie command.

pie set up /

For instance, let’s say you wish to have to put in the xdebug extension to accomplish debugging on your PHP utility. You’ll be able to run:

pie set up xdebug/xdebug

This command will pull the xdebug extension from Packagist, construct it, and set up it on your PHP set up. PIE will even upload the extension for your php.ini report, so that you don’t need to do it manually.

You’ll be able to in finding all extensions that you’ll be able to set up via PIE in Packagist.

Be aware for Home windows

PIE lately does now not strengthen construction extensions on Home windows. It is dependent upon the extension writer to give you the pre-built DLL report for his or her extension, so there are likely some extensions that you’ll be able to’t set up on Home windows.

Wrapping Up

PIE is a smart initiative to simplify the set up of PHP extensions. I love the way it treats extensions as Composer applications, making it more uncomplicated to regulate and replace them. I feel it’s a step in the precise course to modernize the PHP ecosystem and make it extra developer-friendly.

The publish Learn how to Set up PHP Extensions Simply with PIE seemed first on Hongkiat.

WordPress Website Development Source: https://www.hongkiat.com/blog/how-to-install-php-extensions-with-pie/

[ continue ]