StLia StLia - 23 days ago 10
PHP Question

error upgrading php in mac

I am running OSX El Capitan (version 10.11.6).

I had php 5.5 installed.

Phpunit requires php5.6 and more so I tried to upgrade my php to 5.6. I couldn't do it so I gave php7 a try.

I followed these guides:

https://coolestguidesontheplanet.com/upgrade-php-on-osx/

https://php-osx.liip.ch/

Mac upgraded PHP to 5.6, but CLI php -v get 5.3.28?

My current output with

php -v
is :

PHP 7.0.12 (cli) (built: Nov 1 2016 10:21:11) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.12, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans


Funny thing, my output with a
phpinfo();
when called from somewhere inside a Symfony project, is still
PHP Version 5.5.36


Any ideas??

Answer

Terminal uses a different PHP than a HTTP server in browser. You can check what PHP you're using in CLI (command line interface) by this terminal command:

$ which php

I don't know if you use any AMP stack (like MAMP). They include their own PHP, so you need to update them in order to have a different PHP version in browser.

Maybe you can use this trick to determine what PHP versions you use in browser / CLI: Find the php.ini path in your phpinfo() output and compare it with this terminal command:

$ php -i | grep php.ini