Wampserver not changing the PHP version
When you toggle between PHP versions in the WampServer tray icon, it is common to expect an immediate reflection of that change when you run php -v from the command line or access your application via a browser. However, if you are running Windows 10 with WampServer 3.0.6 and observe that the CLI still reports PHP 5.6.25 even after switching to PHP 7.0.10, the issue usually lies in how the environment variables are set for your specific shell session versus the web server configuration.
WampServer manages multiple PHP installations by installing them into separate directories within its installation folder and swapping which one is active via symbolic links (junctions) in the bin/php directory. When you switch versions using the tray icon, WampServer updates these junctions to point to the new executable path. However, the command line interface (cmd.exe) maintains its own isolated environment variables. If your system's PATH variable was manually edited or if a legacy batch file was used to initialize the PHP environment, it might be hardcoded to look for php.exe in a specific location that corresponds to the older version.
To verify this, open a new Command Prompt and run:
where php
This command lists all locations where the system looks for executable files. If the path shown points to C:\wamp\bin\php\php5.6.25 while your WampServer tray icon indicates PHP 7.0.10, the shell environment has not updated correctly. This is a frequent occurrence because WampServer often relies on a specific entry point script or environment setup that needs to be triggered after every service restart. Simply restarting the services via the tray menu updates the Apache and MySQL configurations, but it does not automatically refresh the PATH variable for an already open command prompt window.
The most reliable way to resolve this discrepancy is to ensure that your command line session picks up the active WampServer environment. You can do this by running the wampstart.bat script (if available in your version) or simply closing and reopening the Command Prompt after toggling the PHP version in the tray. In some configurations, you may need to manually update the PATH variable by adding the directory of the currently active PHP version to the front of the list:
set "PATH=C:\wamp\bin\php\php7.0.10;%PATH%"
However, relying on manual PATH manipulation is generally discouraged for production workflows because it can lead to inconsistencies when switching between different WampServer configurations or if other applications depend on PHP. Instead, consider using the wampapache.bat or similar scripts provided by WampServer to initialize the environment correctly before invoking your application logic.
When testing via a browser, the version displayed is determined entirely by the configuration loaded by Apache, not the command line. If Apache shows PHP 7.0.10 in its status page but the CLI shows 5.6.25, it confirms that the web server and the shell are pointing to different executables. This separation of concerns is a core aspect of WampServer's architecture but can be confusing during development if you assume they share the same binary.
If you are developing Laravel applications or other frameworks that require specific PHP extensions or versions for compatibility, relying on the default system PATH can lead to subtle bugs where the framework loads an older extension than intended. In such cases, using a version manager like phpenv-win alongside WampServer provides a more robust solution, allowing you to isolate the PHP environment used by your CLI projects from the one served by Apache. This approach ensures that switching versions does not inadvertently affect global system settings or break existing dependencies.