Learn how to install PHP locally to solve Exercism's exercises on your own machine
We encourage to use a stable PHP release with active support. Currently this is PHP 8.0, 8.1 and 8.2. Details on current releases and their timelines can be found at php.net/supported-versions.
PHP can be downloaded and built from source, available at php.net/downloads.php or windows.php.net/download.
Note: A web server such as nginx or Apache HTTP server is not required to complete the exercises.
Different distributions have different methods. You should be able to
$ yum install php
or
$ apt-get install php
depending on your repository manager.
For further instructions, read the manual on Installation on Unix systems.
While PHP is often bundled with macOS, it is often outdated. We recommended installing PHP through Homebrew. You can install Homebrew following the instructions here.
To confirm its installation try the following command, it should output Homebrew 3.2.x
at the time of this writing.
$ brew --version
Install PHP via homebrew
$ brew install php@8.0
This should display the now installed version of PHP, at least version 8.0.x
.
$ php -v
For further instructions, read the manual on Installation on macOS.
Official PHP binaries for Windows can be downloaded from windows.php.net/download.
There are pre-built stacks including WAMP - (Windows, Apache, MySQL, PHP) and XAMPP.
For further instructions, read the manual on Installation on Windows systems.
If you prefer containerized solutions, you can download official PHP image from Docker Hub. You will also need Docker.
If you want to use a different OS, see instruction on php.net/manual/en/install.
Install Composer here following your devices OS installation instructions. We recommend installing it globally for ease of use.
PHPUnit version 9 can be installed globally via Composer, using the following command.
> composer global require phpunit/phpunit ^9
If you are using PHP 8+ make sure you install at version 9.5 or later.
If you are not using Composer package manager, follow the official Installing PHPUnit instructions.