Back to list

Install PHP on macOS

{{ $t('article.attributes.headline') }}


PHP is missing in Monterey

Starting with macOS Monterey, PHP is no longer included in a default installation of the system. If you want to use PHP on macOS Monterey, you must first install PHP. The following instructions show the Terminal commands to install PHP. To enter a Terminal command, you can copy it from your web browser to the clipboard and then paste it in Terminal and hit the return key to execute the command.

Installing Homebrew

To install Homebrew, see the instructions on the Homebrew installation page and the Homebrew home page. After installing Homebrew, enter the following command in Terminal to verify that Homebrew has successfully been installed:

brew --version

Installing PHP

Once Homebrew is installed, enter the following command to install PHP:

brew install php

This will take a while and will produce some output in the Terminal window. At the end, when you see the input prompt again, check the path of "php" with the following command: command -v php The command should display something like




Now PHP is ready, and you can run PHP scripts on your computer.

Running PHP scripts

Scripts start with a "shebang" line that tells the system where it can find the interpreter for the script language. Up to macOS Big Sur, PHP was pre-installed in the location /usr/bin/php, but now PHP lives at a different path. You will therefore need to update the shebang line in PHP scripts to #!/usr/bin/env php

Using PHP in Typinator

In Typinator, you can use PHP scripts in expansions in two ways:

a. You can store external scripts in the Includes/Scripts folder and then include invocations of these scripts in Typinator expansions. If you already have used PHP scripts before, you need to update the shebang lines in these scripts, as described above in "Running PHP scripts".

b. You can include inline scripts in expansions. A simple inline script in PHP would be:

    echo "Hello";
    echo "Hello";

In this case, Typinator knows where to find the PHP interpreter in both Monterey and in older versions of macOS, but you need at least Typinator 8.11 to run PHP scripts on Monterey. Older versions of Typinator will display an error message that says "script RunPHP.php failed". Typinator 8.11 and newer will even check whether PHP is installed, and it helps you with the installation by displaying these instructions in a web browser.

Save time with Typinator

Enter words, sentences, or even entire paragraphs by typing just a few characters. Save time for the really important things in life.