How to upgrade php version on Windows 10

How to upgrade php version on Windows 10

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

Stefan Bogdanescu

Founder & Senior Architect

Resolving CLI and Web Server PHP Version Mismatches on Windows

Running a Laravel project on a Windows machine often reveals a confusing discrepancy: your web server is using a modern version of PHP, but the command-line interface (CLI) reports an ancient one. This exact scenario occurs when WAMP or similar stack managers install multiple versions of PHP side-by-side. If you run composer update and see an error stating This package requires php >=5.6.4 but your PHP version (5.5.12) does not satisfy that requirement, checking the browser's output might show PHP 7.0.4, while php -v in the console stubbornly displays 5.5.12.

The root cause lies in how Windows executes commands versus how web servers load executables. When you type php -v in your terminal or Git Bash, Windows searches for the executable using the system's PATH environment variable. The screenshot provided in typical troubleshooting posts shows a PATH that likely points to an older installation directory (often associated with legacy Visual C++ runtimes or old WAMP defaults) before reaching the newer version installed by the web server stack. Conversely, Apache or Nginx running under WAMP loads PHP directly from its own configuration files, bypassing the system PATH entirely. This is why the browser sees PHP 7.0.4 while the CLI remains stuck on 5.5.12.

To resolve this, you must ensure the CLI version matches your web server version or exceeds it. The most reliable method involves updating the PATH environment variable to prioritize the newer PHP installation. Locate the directory where the modern PHP (e.g., PHP 7.x) resides within your WAMP folder structure. You will typically find a php.exe file alongside a corresponding php.ini.

  1. Identify the Correct Directory: Check your WAMP installation folder (usually C:\wamp\bin\php\phpX.X.X). Verify that a php.exe exists there.
  2. Edit System Environment Variables: Right-click "This PC" on your desktop, select Properties, then Advanced system settings. Click the "Environment Variables" button. In the User or System variables section (use System if you want it globally), find Path, select it, and click Edit.
  3. Prepend the New Path: Add a new entry pointing to the directory containing the PHP 7.x executable. Ensure this entry appears at the very top of the list so Windows prioritizes it over the old 5.5.12 version.
  4. Restart Your Terminal: Environment changes do not affect currently open terminal windows. You must close and reopen your command prompt or PowerShell session for the new PATH to take effect.

Once the path is updated, running php -v should reflect the newer version immediately. However, there is a critical configuration detail regarding Composer. Laravel projects rely on Composer for dependency management, and Composer has its own strict requirements file (composer.json). If you encounter issues where Composer still complains about PHP versions despite your CLI showing the correct one, it may be because Composer itself is outdated or bundled with an old runtime in some environments.

It is best practice to ensure that both your CLI tool and your web server use the same PHP build to avoid subtle bugs related to extensions or memory limits. If you are moving forward with a new project, consider using the official installer from https://laravelcompany.com which provides streamlined setups for local development environments. This ensures that the underlying runtime matches the framework's expectations right out of the box.

If your application still behaves unexpectedly after aligning the versions, inspect the php.ini file referenced by both CLI and web server. Ensure that extensions like pdo_mysql and mbstring are enabled, as Laravel requires these to function correctly. Finally, always clear Composer's cache if you suspect stale data is interfering with the update process, though version mismatches usually require explicit path correction rather than cache clearing.

Our network