LinuxCommandLibrary

pecl

Install PHP extensions

TLDR

Display a list of available commands

$ pecl
copy

Install a package
$ pecl install [package]
copy

List installed packages
$ pecl list
copy

Upgrade all packages
$ pecl upgrade
copy

Upgrade a specific package
$ pecl upgrade [package]
copy

Uninstall a specific package
$ pecl uninstall [package]
copy

Display information about a specific package
$ pecl info [package]
copy

Update the available package sources
$ pecl update-channels
copy

SYNOPSIS

pecl [global-options] command [command-options] [arguments]

PARAMETERS

-C channel
    Specify the channel to use for the command (e.g., `pecl.php.net`).

-D name=value
    Define a configuration variable for the command (e.g., `ext_dir=/usr/lib/php/modules`).

-E
    Do not enable the extension in `php.ini` after installation.

-F
    Force installation, overwriting existing files or ignoring conflicts.

-P state
    Set the preferred package stability state (e.g., `stable`, `beta`, `devel`).

-Z
    Only download the package, do not install it.

-g
    Do not upgrade dependencies when installing or upgrading a package.

-h, --help
    Display help information for the pecl command or a specific subcommand.

-n
    Non-interactive mode; do not ask any questions, assume 'yes' to prompts.

-q
    Quiet output; suppress most messages, only show errors.

-v
    Verbose output; show more detailed information about the operation.

-V, --version
    Display the pecl version information.

DESCRIPTION

The pecl command is a command-line interface for the PHP Extension Community Library (PECL). PECL serves as a repository for PHP extensions, which are typically written in C and compiled into PHP to add new functionalities or improve performance.

It provides a streamlined way for developers and system administrators to download, compile, install, upgrade, and uninstall PHP extensions. Instead of manually downloading source code, running `phpize`, configuring, compiling with `make`, and then editing `php.ini`, pecl automates most of these steps.

This tool is crucial for extending PHP's capabilities with community-contributed modules that are not bundled with the core PHP distribution. It helps maintain consistency in extension management and ensures that dependencies are handled correctly, integrating new functionalities seamlessly into your PHP environment.

CAVEATS

Using pecl often requires development tools like a C compiler (e.g., `gcc`) and PHP development headers (e.g., `php-dev` or `php-devel` package on most Linux distributions). Without these, extensions cannot be compiled.

Installations may require root privileges (e.g., `sudo`) if installing to system-wide PHP directories. Care must be taken to ensure extensions are compatible with the specific PHP version in use. Misconfigurations or compilation failures can lead to PHP not starting or unexpected behavior.

COMMON COMMANDS

Some of the most frequently used pecl commands include:
install package-name: Downloads, compiles, and installs a PHP extension.
uninstall package-name: Removes an installed PHP extension.
list: Lists all locally installed PECL packages.
search search-term: Searches the PECL channel for packages matching the term.
update-channels: Updates the list of available PECL channels.
upgrade package-name: Upgrades an installed PHP extension to its latest stable version.

INSTALLATION WORKFLOW

A typical pecl installation workflow involves:
1. Discovery: `pecl search extension` to find the desired package.
2. Installation: `pecl install extension` which downloads the source, runs `phpize`, configures, compiles, and installs the extension into PHP's extension directory.
3. Configuration: If not automatically enabled (e.g., via `pecl install -E`), add `extension=extension-name.so` to your `php.ini` file.
4. Verification: Restart your web server/PHP-FPM and check `php -m` or `phpinfo()` for the newly installed extension.

HISTORY

The pecl command and its underlying system were developed as a counterpart to PEAR (PHP Extension and Application Repository). While PEAR focused on pure PHP code packages, PECL was specifically designed for managing PHP extensions written in C. It emerged in the early 2000s, alongside the development of PHP 4 and 5, to standardize the distribution and installation of compiled PHP modules. Its creation addressed the growing need for a robust system to manage complex, compiled extensions, ensuring they could be easily integrated into various PHP environments without extensive manual compilation and configuration.

SEE ALSO

php(1), php-config(1), phpize(1), composer(1), make(1)

Copied to clipboard