PHP Installer for Extensions (PIE) is a tool designed to simplify the installation and management of PHP extensions. It provides a straightforward way to install PHP extensions without manually compiling or configuring them. PIE uses precompiled binaries when possible, making the process more accessible and user-friendly.
PHP comes with quite a number of core extensions already included, and some additional extensions can be installed through an OS package manager, such as Apt, Yum, Homebrew, etc, on Linux and MacOS or as precompiled binaries on Windows. However, sometimes, you need to install other extensions that might still need to be precompiled and available via those options. In those instances, you would need to utilize something like PECL or compile the extension manually from the source.
The PHP Foundation has recently introduced a pre-release of the PHP Installer for Extensions (PIE). PIE aims to simplify managing PHP extensions by providing a modern, flexible alternative to PECL and treating extensions as first-class citizens in the PHP ecosystem.
The whole point of this project is to help make the process of managing PHP extensions more streamlined. Now, extensions can be distributed via Packagist, just like regular PHP packages! As a result, the installation and update process of extensions will be quite familiar to developers who already use Composer.
Note that as of the writing of this article, this project is still in active development, and there is an initial pre-release that is stable and available as a PHAR download. You will also need PHP 8.1 or newer to run PIE, but PIE can install an extension to any installed PHP version. The PHP Foundation is inviting developers to try it and share feedback.
Key Features of PIE:
- Cross-Platform Compatibility: Works on multiple operating systems like Windows, macOS, and Linux.
- Simplified Installation: Automates the process of installing PHP extensions, avoiding the need for manual downloads and compilation.
- Dependency Management: Automatically resolves dependencies for extensions.
- Version Handling: Ensures compatibility with your PHP version and provides options to manage different PHP versions.
- CLI Tool: Comes with a command-line interface for managing extensions.
How to Use PIE:
- Install PIE: Download and install PIE from its official repository or distribution.
- Install Extensions:
pie install <extension-name>
- For example, to install the
redis
extension:pie install redis
- For example, to install the
- List Available Extensions:
pie list
- Uninstall an Extension:
pie remove <extension-name>
Benefits of PIE:
- Reduces the complexity of dealing with PHP extensions.
- Helps in maintaining consistent environments across development and production.
- Saves time and effort, especially for developers who frequently switch between projects requiring different extensions.
If you’re planning to use it, check the documentation or community for updates and best practices to ensure smooth integration into your workflow.