shivammathur / homebrew-php

:beer: Homebrew tap for PHP 5.6 to 8.4. PHP 8.4 is built nightly.

Home Page:https://github.com/shivammathur/homebrew-php/packages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not possible to switch to php 8.1

acrobat opened this issue · comments

Can't switch to php 8.1 from any version

→ php -v
PHP 8.0.13 (cli) (built: Nov 28 2021 14:26:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies
    with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
→ brew link --overwrite --force shivammathur/php/php@8.1
Warning: Already linked: /opt/homebrew/Cellar/php/8.1.1
To relink, run:
  brew unlink php && brew link php

php itself is still 8.0

→ php -v
PHP 8.0.13 (cli) (built: Nov 28 2021 14:26:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies
    with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans

I've found some issues around this so I did the following, but the problem persists

  • brew update
  • brew uninstall shivammathur/php/php@8.1
  • brew install shivammathur/php/php@8.1
→ brew install shivammathur/php/php@8.1
==> Downloading https://ghcr.io/v2/shivammathur/php/php/manifests/8.1.1
Already downloaded: /Users/jeroen.thora/Library/Caches/Homebrew/downloads/21e600f20e826c1377a97e468dc8ecbb34e60412274bfba4cf5940c581506e4c--php-8.1.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/shivammathur/php/php/blobs/sha256:8ed33af0625dc9bbd492914f64f461a702bc8f8a1c3fda39d75295468e6a140c
Already downloaded: /Users/jeroen.thora/Library/Caches/Homebrew/downloads/80fe8723a45d0febfae210074c875d239c0911e9f4b25814c148adaf637dcd49--php--8.1.1.arm64_big_sur.bottle.tar.gz
==> Installing php from shivammathur/php
==> Pouring php--8.1.1.arm64_big_sur.bottle.tar.gz
Unlinking /opt/homebrew/Cellar/php@8.0/8.0.13_3... 50 symlinks removed.
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set php_ini /opt/homebrew/etc/php/8.1/php.ini system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set php_dir /opt/homebrew/share/pear system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set doc_dir /opt/homebrew/share/pear/doc system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set ext_dir /opt/homebrew/lib/php/pecl/20210902 system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set bin_dir /opt/homebrew/opt/php/bin system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set data_dir /opt/homebrew/share/pear/data system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set cfg_dir /opt/homebrew/share/pear/cfg system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set www_dir /opt/homebrew/share/pear/htdocs system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set man_dir /opt/homebrew/share/man system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set test_dir /opt/homebrew/share/pear/test system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear config-set php_bin /opt/homebrew/opt/php/bin/php system
==> /opt/homebrew/Cellar/php/8.1.1/bin/pear update-channels
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/8.1/

To restart shivammathur/php/php after an upgrade:
  brew services restart shivammathur/php/php
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize
==> Summary
🍺  /opt/homebrew/Cellar/php/8.1.1: 512 files, 81.8MB
==> Running `brew cleanup php`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

@acrobat

Please run

brew unlink php@8.1
brew link php@8.1

Restart your terminal and check php -v

If that does not fix it, please let me know the output of echo $PATH.

@shivammathur That does indeed work, but I have the same problem if I switch versions again afterwards.

# brew unlink php@8.1
# brew link php@8.1
# Restart terminal

→ php -v
PHP 8.1.1 (cli) (built: Dec 15 2021 09:38:20) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies
    with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans

→ brew link --overwrite --force shivammathur/php/php@8.0
Linking /opt/homebrew/Cellar/php@8.0/8.0.13_3... 838 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/opt/homebrew/opt/php@8.0/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/opt/homebrew/opt/php@8.0/sbin:$PATH"' >> ~/.zshrc

→ php -v
PHP 8.0.13 (cli) (built: Nov 28 2021 14:26:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies
    with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
    with blackfire v1.73.0~mac-x64-non_zts80, https://blackfire.io, by Blackfire

→ brew link --overwrite php@8.1
Warning: Already linked: /opt/homebrew/Cellar/php/8.1.1
To relink, run:
  brew unlink php && brew link php

→ brew link --overwrite php@8.0
Warning: Already linked: /opt/homebrew/Cellar/php@8.0/8.0.13_3
To relink, run:
  brew unlink php@8.0 && brew link --force php@8.0

The result of echo $PATH

/opt/homebrew/opt/openjdk@11/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/opt/mysql@5.7/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

When you try to link it and it is already linked it will ask you to unlink it and link it again.

In fact, you can always try to unlink the version you are trying to switch to and link it again.
Say to switch to PHP 8.0

brew unlink php@8.0
brew link --force --overwrite php@8.0