{"id":1090,"date":"2025-01-08T12:00:03","date_gmt":"2025-01-08T13:00:03","guid":{"rendered":"http:\/\/www.diveintoaccessibility.com\/?p=1090"},"modified":"2025-04-30T10:21:13","modified_gmt":"2025-04-30T10:21:13","slug":"how-to-install-php-extensions-easily-with-pie","status":"publish","type":"post","link":"http:\/\/www.diveintoaccessibility.com\/index.php\/2025\/01\/08\/how-to-install-php-extensions-easily-with-pie\/","title":{"rendered":"How to Install PHP Extensions Easily with PIE"},"content":{"rendered":"

Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from source. These methods could be inconsistent across platforms and required different commands, making the process complex and prone to errors.<\/p>\n

PECL<\/a>, while helpful, feels antiquated. It\u2019s not as easy to put your extension in PHP as it is with Composer. PIE<\/a> is an initiative from the PHP Foundation<\/a> to solve this by treating extensions as Composer packages. It simplifies the process, offers better cross-platform consistency, and ensures easier updates and management for PHP extensions.<\/p>\n

Prerequisites<\/h2>\n

Before we begin, ensure you have PHP 8.1 or newer to run PIE. However, PIE can install extensions for any installed PHP version. To check the PHP version on your computer, you can run: php -v<\/code><\/p>\n

\"Checking<\/figure>\n

Installation<\/h2>\n

To install the PHP Installer for Extensions (PIE), you can follow these steps:<\/p>\n

1. Download the PHAR package<\/h3>\n

First, you need to download the pie.phar<\/code> file from the official repository or website<\/a>. This is the primary file needed to use PIE.<\/p>\n

2. PHAR installation<\/h3>\n

Move pie.phar<\/code> into your computer\u2019s PATH<\/code>, such as \/usr\/local\/bin\/<\/code>, so you can run it from anywhere. You can rename it for convenience, for example:<\/p>\n

\r\nmv pie.phar \/usr\/local\/bin\/pie\r\n<\/pre>\n

On Windows, you can move it to C:Program Files<\/code> or any other directory in your PATH<\/code>. However, I recommend using Composer and its CLI with the Windows Subsystem for Linux (WSL) for a better experience.<\/p>\n

3. Make it executable<\/h3>\n

On non-Windows machines, you need to change the permissions to make it executable.<\/p>\n

\r\nchmod +x \/usr\/local\/bin\/pie\r\n<\/pre>\n

That\u2019s it. You can try running pie<\/code> in your terminal to see if it\u2019s installed correctly.<\/p>\n

\"Checking<\/figure>\n

We can now use PIE to install PHP extensions with ease using the pie<\/code> command.<\/p>\n

\r\npie install <vendor>\/<package>\r\n<\/pre>\n

For example, let\u2019s say you want to install the xdebug<\/code> extension to perform debugging in your PHP application. You can run:<\/p>\n

\r\npie install xdebug\/xdebug\r\n<\/pre>\n

This command will pull the xdebug<\/code> extension from Packagist, build it, and install it in your PHP installation. PIE will also add the extension to your php.ini<\/code> file, so you don\u2019t have to do it manually.<\/p>\n

You can find all extensions that you can install through PIE in Packagist<\/a>.<\/p>\n

Note for Windows<\/h2>\n

PIE currently does not support building extensions on Windows. It relies on the extension author to provide the pre-built DLL file for their extension, so there are probably some extensions that you can\u2019t install on Windows.<\/p>\n

Wrapping Up<\/h2>\n

PIE is a great initiative to simplify the installation of PHP extensions. I like how it treats extensions as Composer packages, making it easier to manage and update them. I think it\u2019s a step in the right direction to modernize the PHP ecosystem and make it more developer-friendly.<\/p>\n

The post How to Install PHP Extensions Easily with PIE<\/a> appeared first on Hongkiat<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from source. These methods could be inconsistent across […]<\/p>\n","protected":false},"author":1,"featured_media":1092,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/posts\/1090"}],"collection":[{"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/comments?post=1090"}],"version-history":[{"count":3,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/posts\/1090\/revisions"}],"predecessor-version":[{"id":1095,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/posts\/1090\/revisions\/1095"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/media\/1092"}],"wp:attachment":[{"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/media?parent=1090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/categories?post=1090"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/tags?post=1090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}