Installing PHP
To run PHP on your own computer you need the PHP interpreter, a command you'll call php. It's free and runs on Windows, macOS and Linux, and it includes a small web server for development, so you don't need Apache or nginx to learn. This lesson installs PHP 8.5, checks it works, and sets up an editor.
Windows
The simplest option is the Windows package manager:
winget install PHP.PHP.8.5
Alternatively, download the "VS16 x64 Non Thread Safe" zip from windows.php.net/download, extract it to a folder such as C:\php, and add that folder to your PATH environment variable. In the folder, copy php.ini-development to php.ini — it turns on helpful error messages. All-in-one bundles such as Laragon or XAMPP also include PHP along with a database and web server.
macOS
macOS doesn't come with PHP. Install it with Homebrew:
brew install php
Homebrew installs the latest release and keeps it updated with brew upgrade.
Linux
Use your distribution's package manager. On Ubuntu and Debian:
sudo apt update sudo apt install php-cli php-mbstring php-sqlite3 php-xml
On Fedora use sudo dnf install php-cli php-mbstring php-pdo. Distributions sometimes ship an older PHP version; on Ubuntu and Debian, the widely used ppa:ondrej/php repository provides the latest releases.
Using Docker
If you use Docker, the official image runs PHP without installing anything on your system:
docker run --rm -it -v "$PWD":/app -w /app php:8.5-cli php hello.php
Checking the installation
Open a new terminal and ask for the version:
php -v
PHP 8.5.8 (cli) (built: Jul 7 2026 04:56:07) (NTS clang 17.0.0)
The build details after the version number vary between installations. Any version starting with 8.5 (or later) works for this course; most examples also run on 8.3 and 8.4. A few more useful commands:
| Command | Shows |
|---|---|
php -m | Installed extensions (look for mbstring, pdo_sqlite, json) |
php --ini | Which php.ini configuration file is loaded |
php -i | Every configuration setting |
php -a | An interactive shell for trying one-liners |
Configuration for development
PHP's settings live in php.ini. For learning, make sure errors are shown — otherwise a mistake just produces a blank page. These lines in php.ini (they're the defaults in php.ini-development) do it:
display_errors = On error_reporting = E_ALL
On a live server you do the opposite: hide errors from visitors and write them to a log file instead (lesson 63).
Choosing an editor
| Editor | Notes |
|---|---|
| Visual Studio Code | Free. Install the PHP Intelephense extension for code completion, error checking and go-to-definition. |
| PhpStorm | JetBrains' full PHP IDE with excellent refactoring and debugging; free for non-commercial use. |
| Any text editor | PHP files are plain text — the examples only need a terminal and the php command. |
Running PHP without installing
Online sandboxes such as 3v4l.org run snippets against many PHP versions — handy for checking how behaviour changed between versions. For anything involving files, forms or databases, a local installation is much better.