0

At the moment I'm using two machines for Web (Win10) & iOS development (MacOS) and looking to combine them into a one computer that I would use on a daily basis.

My current challenge is to ensure that I can develop and run two or more environments on the same machine (not necessary at the same time, a simple switch would do the job).

I've tried MAMP and AMPPS and they both do the job, with an exception to the PHP-CLI version.

Every time I run php from the console it opens up the latest version completely ignoring the one that is specified by the MAMP or AMPPS.

What is the best way to ensure that php-cli always points to a currently active version of the PHP as stipulated by MAMP or AMPPS?

On Windows I was using https://ospanel.io/ that had it's own internal terminal window that would automatically load the current version of php-cli.

I am fully aware of docker/vagrant but they would be an overkill in this case.

Thanks

RomanG
  • 128
  • 7
  • Dont put php folder on the OS PATH. Instead, write a little batch file [like this to access the CLI](https://stackoverflow.com/questions/15597067/how-to-run-php-from-windows-command-line-in-wampserver/16289254#16289254) – RiggsFolly Jul 29 '18 at 23:48
  • You could use PHPBrew for that (http://phpbrew.github.io/phpbrew/) – Roman Jul 29 '18 at 23:56
  • Run your separate versions in vagrant or docker. – ryantxr Jul 30 '18 at 00:33

2 Answers2

0

Unfortunately there is no simple answer to my question. As a solution:

  • Get multiple version installed
  • Design a script that changes the PATH environment to the right version as required.

alternatively a script that rewrites a symlink to a required version of the PHP.

RomanG
  • 128
  • 7
0

For MAMP user, you must edit the file /usr/local/etc/httpd/httpd.conf and set the PHP version you prefer to use in your stack. I only installed one version of Apache HTTPD with multiple PHP versions - you have to specify the version.

If you don't, the default is the Mac's pre-installed PHP version.

Oscar Gallardo
  • 2,240
  • 3
  • 27
  • 47
JR DEV
  • 21
  • 3