Quick Answer
Fix PHP CLI path issues on Windows.
Understanding the Issue
This occurs when the PHP executable is not in the system PATH, preventing it from being recognized in command prompt.
The Problem
This code demonstrates the issue:
Cmd
Error
C:> php -v
'php' is not recognized...
The Solution
Here's the corrected code:
Cmd
Fixed
:: Solution 1: Add PHP to PATH
:: 1. Right-click Computer > Properties > Advanced system settings
:: 2. Environment Variables > System variables > Path > Edit
:: 3. Add path to PHP folder (e.g., C:php)
:: 4. Restart command prompt
:: Solution 2: Use full path
C:phpphp.exe -v
:: Solution 3: Verify installation
:: Check php.exe exists in installation directory
Key Takeaways
Ensure PHP directory is correctly added to system PATH.