PHP Command, not found

PHP Command, not found

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

Stefan Bogdanescu

Founder & Senior Architect

PHP Command, not found

When you attempt to install Composer on a Linux system by running php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" or similar scripts, the shell immediately rejects your input with bash: php: command not found. This error is a binary path resolution issue, not a syntax error in your script. Your system simply cannot locate the executable named php in the directories listed in your current session's $PATH environment variable.

The most common misconception occurs when developers assume that installing PHP via a graphical installer like XAMPP automatically configures the command-line interface (CLI) for the host OS. XAMPP bundles a PHP interpreter, but it often installs it in a directory outside of standard system paths (like /opt/lampp or similar) and does not automatically append it to your shell's $PATH. Consequently, when you run php from your terminal, the shell looks in /usr/bin, /usr/local/bin, and other standard locations, fails to find the XAMPP binary, and returns the "command not found" error.

To resolve this, you must explicitly add the path to your PHP binary to your environment variables. The most robust method is to edit your shell configuration file, typically ~/.bashrc for Bash or ~/.zshrc for Zsh. You do not need to run a find command across the entire filesystem to locate the binary; instead, you should know where XAMPP installed it during installation. If you are unsure, check the installation directory of your XAMPP instance, which is usually something like /opt/lampp/php.

Once you identify the path—for example, /opt/lampp/bin/php—you can append the following line to your ~/.bashrc:

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

After adding this line, you must reload your shell configuration for the changes to take effect immediately. You can do this by running:

source ~/.bashrc

Verify the fix by typing which php. If it now returns the full path to your XAMPP binary, the command is recognized.

However, relying on a local installation like XAMPP for CLI tasks introduces significant friction when working on Linux distributions like Manjaro. XAMPP is designed primarily for Windows and macOS environments where Apache and MySQL are bundled together out of the box. On Arch-based systems, mixing system-level packages (like pacman) with manually installed binaries can lead to dependency conflicts or version mismatches. For instance, while you might attempt to install php7-cli via the package manager, as seen in your error log, this specific package name may not exist because Manjaro uses a rolling release model where PHP versions change frequently and are often referred to simply as php rather than php7-cli.

If you intend to develop modern web applications, particularly those built with frameworks like Laravel, relying on XAMPP's CLI is generally discouraged. The official LaravelCompany resources and the broader PHP community recommend using a dedicated PHP version manager or installing PHP directly from your distribution's repositories. Tools like phpenv, rbenv, or simply managing multiple versions via parley (for Manjaro/Arch) allow you to switch between different PHP versions seamlessly without polluting your system environment with XAMPP binaries.

For a clean setup on Manjaro, consider removing the XAMPP installation if it is not strictly required for local Apache hosting. Instead, install PHP and its extensions directly via pacman or use the official Arch User Repository (AUR) helpers to get the latest stable versions. This ensures that your CLI tools match the system libraries, preventing "command not found" errors and ensuring that Composer can execute its installation script without permission or path issues.

Our network