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 7.3

 PHP Script File Syntax

 PHP Data Types and Data Literals

 Variables, References, and Constants

 Expressions, Operations and Type Conversions

 Conditional Statements - "if" and "switch"

 Loop Statements - "while", "for", and "do ... while"

 Function Declaration, Arguments, and Return Values

 Arrays - Ordered Maps

 Interface with Operating System

 Introduction of Class and Object

 Integrating PHP with Apache Web Server

 Retrieving Information from HTTP Requests

 Creating and Managing Sessions in PHP Scripts

 Sending and Receiving Cookies in PHP Scripts

 Controlling HTTP Response Header Lines in PHP Scripts

 Managing File Upload

 MySQL Server Connection and Access Functions

 Functions to Manage Directories, Files and Images

 SOAP Extension Function and Calling Web Services

 SOAP Server Functions and Examples

 Localization Overview of Web Applications

 Using Non-ASCII Characters in HTML Documents

 Using Non-ASCII Characters as PHP Script String Literals

 Receiving Non-ASCII Characters from Input Forms

 "mbstring" Extension and Non-ASCII Encoding Management

 Managing Non-ASCII Character Strings with MySQL Servers

 Parsing and Managing HTML Documents

 Configuring and Sending out Emails

 Image and Picture Processing

 Managing ZIP Archive Files

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

 Outdated Tutorials

 References

 Full Version in PDF/EPUB