pecl:command not found

pecl:command not found

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

pecl:command not found

When you execute pecl download memcached and receive a pecl: command not found error, the issue isn't with PECL itself or your PHP installation per se. It is almost exclusively a path resolution failure. Your shell environment cannot locate the pecl executable because it resides outside your default $PATH.

On macOS systems running Intel processors (x86_64), this is particularly common for developers using Homebrew to manage dependencies. When you install PHP via Homebrew, the installation directory is typically /opt/homebrew on Apple Silicon or /usr/local on Intel machines. However, the pecl binary lives in a subdirectory like /opt/homebrew/bin/. Unless you have explicitly added this location to your shell's execution path, the command fails immediately before PHP can even check its configuration files.

You can verify the exact location of the missing executable by searching for it on your file system. Run the following command:

which pecl

If this returns nothing, try a broader search using find or locate:

sudo find /usr/local -name "pecl" 2>/dev/null
# Or for Apple Silicon
sudo find /opt/homebrew -name "pecl" 2>/dev/null

Once you identify the path, say /opt/homebrew/bin/pecl, you have two immediate options to resolve the error. The quickest fix is to prefix your command with the full path:

/opt/homebrew/bin/pecl download memcached

While this works, it is prone to human error and breaks scripts that rely on standard commands. A more robust solution involves modifying your shell configuration file—such as ~/.zshrc for Zsh or ~/.bash_profile for Bash—to include the PHP binaries in your $PATH. Append the following line to your config:

export PATH="/opt/homebrew/bin:$PATH"

After saving the file, reload your shell configuration with source ~/.zshrc. Running pecl download memcached again should now succeed.

However, simply downloading the extension is rarely enough for modern PHP development. The download command retrieves a .tgz archive containing C source code and build scripts. To actually use the extension, you must compile it against your specific PHP installation. If you attempt to install via Composer without verifying that PECL can successfully compile the module, you will encounter runtime errors where functions like memcached_get are undefined.

Before proceeding with a fresh download, check if an older version of the extension is already compiled and available:

php -m | grep memcached

If it appears in the list, your environment is configured correctly, and you can skip the PECL steps entirely. If it does not appear, you must run pecl install instead of just download. The install command handles both fetching the source and compiling it.

pecl install memcached
echo "extension=memcached.so" >> /opt/homebrew/etc/php/8.2/php.ini

Note the version-specific behavior here. Modern PHP versions (8.0+) often require specific PECL channels or may have deprecated certain legacy packages. Additionally, compiling extensions requires a working C compiler and development headers installed on your system. If you receive errors during compilation regarding missing libraries, ensure that libmemcached is installed first:

brew install libmemcached
pecl install memcached

This sequence ensures that the compiled binary links correctly against the required dependencies. Once the module is loaded in php.ini, restart your PHP-FPM service or Apache server to apply the changes. Always verify the final state by checking the module list again; if it remains absent, re-examine your php.ini file for syntax errors or incorrect path references to the .so file generated during installation.

Our network