Upgrade PHP Engine on macOS

This section provides notes on upgrade PHP on macOS computers. There seems to be no PHP binary package available in Homebrew repository for macOS 10.12.

Here is what I did to upgrade the PHP engine on my macOS computer.

1. Search for PHP binary packages managed by Homebrew:

herong$ brew search php

==> Formulae
php@7.2
phplint
phpmyadmin
phpunit
php
php-cs-fixer
php@7.3
...

2. Get the "php" package information:

herong$ brew info php

php: stable 7.4.12, HEAD
General-purpose scripting language
https://www.php.net/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
...
==> Options
--HEAD
  Install HEAD version
==> Caveats
...

3. Install "php" package.

herong$ brew install php

Error:
  homebrew-cask is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow

This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!

Warning: You are using macOS 10.12.
We (and Apple) do not provide support for this old version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
old version.

Error: php: no bottle available!
You can try to install from source with e.g.
  brew install --build-from-source php
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.

4. Upgrade brew:

herong$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow

remote: Enumerating objects: 94461, done.
remote: Counting objects: 100% (91037/91037), done.
remote: Compressing objects: 100% (28031/28031), done.
remote: Total 83177 (delta 61120), reused 77072 (delta 55130), pack-reused 0
Receiving objects: 100% (83177/83177), 39.20 MiB | 5.31 MiB/s, done.
Resolving deltas: 100% (61120/61120), completed with 5002 local objects.
From https://github.com/Homebrew/homebrew-cask
   6c13600ce5..125cd9a5ca  master     -> origin/master

5. Try to install PHP again. It sill says "php: no bottle available!"

herong$ brew install php

Updating Homebrew...
==> Auto-updated Homebrew!

Warning: You are using macOS 10.12.
...

Error: php: no bottle available!
...

Looks like I need to upgrade my macOS 10.12 to a newer release. I will do it later.

Table of Contents

 About This Book

 Introduction and Installation of PHP

Managing PHP Engine and Modules on macOS

 PHP Version Pre-Installed on macOS

Upgrade PHP Engine on macOS

 Managing PHP Engine and Modules on CentOS

 cURL Module - Client for URL

 DOM Module - Parsing HTML Documents

 GD Module - Manipulating Images and Pictures

 MySQLi Module - Accessing MySQL Server

 OpenSSL Module - Cryptography and SSL/TLS Toolkit

 PCRE Module - Perl Compatible Regular Expressions

 SOAP Module - Creating and Calling Web Services

 SOAP Module - Server Functions and Examples

 Zip Module - Managing ZIP Archive Files

 References

 Full Version in PDF/EPUB