Current Location: Home> Latest Articles> PHP Guide to Installing, Uninstalling, and Managing Extensions Using PECL Tool

PHP Guide to Installing, Uninstalling, and Managing Extensions Using PECL Tool

gitbox 2025-06-13

1. Installing the PECL Tool

Before using the PECL tool, you need to install the php-pear package. You can install it with the following command:

apt-get install php-pear

After installation, both the PECL tool and its dependency, the pear tool, will be installed and added to the system's environment variables. You can check if the installation was successful with the following command:

pecl version

If you see the version information of PECL, the installation was successful.

2. Installing PHP Extensions Using PECL

Using PECL to install PHP extensions is straightforward. Simply use the following command:

pecl install extension_name

For example, to install the Redis extension, use this command:

pecl install redis

During installation, the system may prompt you to configure the extension. If configuration is required, enter “yes”; otherwise, enter “no”.

3. Uninstalling PHP Extensions Using PECL

If you need to uninstall an already installed extension, you can use the following command:

pecl uninstall extension_name

For example, to uninstall the Redis extension, use this command:

pecl uninstall redis

4. Listing Installed Extensions

To list all the extensions currently installed on your system, use the following command:

pecl list

This command will display all the PHP extensions that are currently installed.

5. Updating PHP Extensions Using PECL

If you need to update an installed extension, you can use the following command:

pecl upgrade extension_name

For example, to update the Redis extension, use this command:

pecl upgrade redis

6. Searching for Extensions

If you're not sure about the name of an extension, you can search for it using PECL:

pecl search extension_name

For example, to search for extensions related to memcached, use this command:

pecl search memcached

7. Conclusion

This article provides a detailed overview of how to use the PECL tool, including how to install, uninstall, update, list, and search for extensions. With PECL, developers can easily manage PHP extensions and improve their development efficiency.