skip to Main Content

In my mac (version 10.13.6 High Sierra) php -v output is PHP 7.1.32 .
I need to update this 7.1 version to 7.3.

i tried to remove this version using brew unlink php7.1 but it’s not worked.

How can i upgrade php version.

4

Answers


  1. Chosen as BEST ANSWER

    $ brew upgrade php : ( get the latest homebrew php packages )

    $ brew install [email protected] : ( Install php 7.4 )

    $ brew link [email protected] : ( create an alias to this keg-only version; see comments output during installation )

    $ echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile : ( Add the alias to your path; see comments output during installation )

    $ source ~/.bash_profile : ( Reload .bash_profile to use the new settings immediately )

    Reference : How to use the php that brew installed?


  2. I am not sure about the 10.13.6 High Sierra version, but this worked for me.

    1. php -v (To see what version php has. But you have already done that)

    2. brew unlink php55 (In my case I use php 5.5)

    3. brew install php73 (For the php 7.3 version.)

    4. php -v (To check of the version is the one I need.)

    Hope this helps.

    Login or Signup to reply.
  3. First:

    ~ brew update
    

    then install the latest php version (PHP 8.0.8 in the time of writing):

    ~ brew install php 
    

    link new version to /usr/local/Cellar/php/8.0.8:

    ~ brew link php
    

    then open the shell’s resource file, located in ~/ (in my case Z-shell or ZSH):

    ~ sudo vi .zshrc
    

    press i to insert and somewhere in your resource file append a new path to your $PATH variable, like this:

    export PATH=$PATH:/usr/local/opt/[email protected]/bin
    

    or in the case of ZSH, you should also be able to do it like this:

    path+=('/usr/local/opt/[email protected]/bin')
    export PATH
    

    then press esc to escape from insert mode, and press :wq to save/write and quit the editor. The final step is to source the file to apply new changes permanently.

    ~ source .zshrc
    

    Try new PHP version:

    ~ php -v
    
    Login or Signup to reply.
  4. I solved the problem maintaining homebrew for both of the arch (arm64 and x86_64).
    In that case I choose Homebrew location dynamically depending on the terminal arch in my .bashrc.

    if [[ $(uname -m) == "x86_64" ]]; then
      echo "x86_64 detected" 
      export PATH=/usr/local/Homebrew/bin:$PATH
    else
      echo "arm64 detected"
      export PATH=/opt/homebrew/bin:$PATH
    fi
    

    And installed tmux in both of the terminal (native and rosetta) and after reload it works correctly. Full .zshrc can be found here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search