I have to work in Magento 2.1.7 and Magento 2.2.5 and for that, I need to install a different version of PHP, I have installed multiple xampp with different port no which resolves PHP requirement.

But now to run Magento CLI with different PHP version is my problem.

Every time to run older Magento I have to change Environment variable in my system. Is there any other workaround for this?

I know windows is not recommended for the Magento 2 development. But I have to use it.


1 Answer 1


There is a simple way to go about it. You just have to use the full path when invoking php in the CLI. So for instance instead of php bin/magento setup:di:compile you will use the full path like this C:\wamp\bin\php\php bin\magento setup:di:compile

You can further try aliases for your php versions, to make it simpler.

  • you are right in case of wamp it is working. I have tested it by running a script with by installing wamp, but in case of xampp it is not. I have tried to use d:/Projects/New_Xampp/php bin/magento -v which throws following message bash: d:/Projects/New_Xampp/php: Is a directory
    – Knight017
    Sep 12, 2018 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.