How to update PHP CLI OSX?

16,029

Solution 1

Just Export installed PHP path ,type this on Terminal

export PATH=/usr/local/php5/bin:$PATH

Solution 2

I checked that /usr/local/php5/bin/php existed. It did, so I added /usr/local/php5/bin to my PATH.

Thank you @AD7six

Solution 3

The answer shared by both Chutipong Roobklom and user1168427 helped, if you want to update to the latest php cli which is 7.2.7 (most current and stable release as of 2018 when this post was created originally so check the latest php version, methods for switching versions may vary) then just use this instead of the php5 command. export PATH=/usr/local/php7/bin:$PATH then type php -v and you should have something that reads like this(on MACOSX by the way):

PHP 7.2.7 (cli) (built: Jun 22 2018 06:27:50) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.7, Copyright (c) 1999-2018, by Zend Technologies

so you shouldn't be getting any errors. Hope this helps and for Kamel, that is how it is installed. You're kind of 'exposing' it in a way for your machine to now recognize which php version you are using.

Share:
16,029
user1168427
Author by

user1168427

Updated on June 21, 2022

Comments

  • user1168427
    user1168427 almost 2 years

    I just updated to php 5.4 using http://php-osx.liip.ch/ on osx lion.

    when i type:

    php -v
    

    i still see:

    PHP 5.3.15 with Suhosin-Patch (cli) (built: Jul 31 2012 14:49:18) 
    Copyright (c) 1997-2012 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    

    But phpinfo() shows 5.4.

    How do i update this?