Skip to main content

Install PHP 8.4, Composer, and VS Code

A clean, properly configured development environment is the foundation of every professional PHP project. It eliminates the “works on my machine” problem, speeds up your workflow, and ensures you’re using the same modern tooling as production systems. In this guide, you’ll set up a complete PHP 8.4 environment step by step on Windows, macOS, or Linux.

By the end, you will have:

  • PHP 8.4 – the latest stable release with JIT, fibers, and property hooks.
  • Composer – the PHP dependency manager used by every modern project.
  • Git – the version control system that tracks your code changes.
  • Visual Studio Code – a powerful, free code editor with excellent PHP support.

Docker users: If you prefer containerized development, we cover Docker‑based PHP environments in the Ecosystem section. This guide focuses on a native installation for learning and small projects.

What You Will Install​

ToolPurposeRequired
PHP 8.4The PHP interpreter and runtimeYes
ComposerDependency manager and autoloader generatorYes
GitVersion controlStrongly recommended
VS CodeCode editor with PHP intelligenceRecommended

System Requirements​

  • Windows 11 (Windows 10 also works)
  • macOS Ventura or later (Monterey works with slightly older packages)
  • Ubuntu 22.04/24.04 LTS or Debian 12+

Hardware: at least 4 GB RAM, 5 GB free disk space, and an internet connection for downloading packages.

Install PHP 8.4​

The installation method varies by operating system. Follow the section for your OS.

Windows​

  1. Visit the PHP for Windows download page and locate the PHP 8.4.x section.
  2. Download the Thread Safe ZIP package (for example php-8.4.0-Win32-vs17-x64.zip).
  3. Create a folder C:\php and extract the ZIP contents there.
  4. Add C:\php to your system PATH:
    • Open Edit the system environment variables from the Start menu.
    • Click Environment Variables.
    • Under System variables, select Path and click Edit.
    • Add a new entry: C:\php.
    • Click OK on all dialogs.
  5. In the C:\php folder, copy php.ini-development to php.ini. Open php.ini and enable the following lines by removing the leading ;:
    extension_dir = "ext"
    extension=mbstring
    extension=openssl
    extension=curl
    extension=fileinfo
  6. Open a new PowerShell window and verify:
    php -v
    You should see PHP 8.4.x (cli) ....

macOS​

We’ll use Homebrew. Install Homebrew first if you haven’t already.

brew update
brew install php@8.4

After installation, link the new PHP version:

brew link --overwrite --force php@8.4

To make this PHP the default in your terminal, add Homebrew’s PHP path to your shell configuration (~/.zshrc for Zsh):

echo 'export PATH="/usr/local/opt/php@8.4/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Verify:

php -v

Ubuntu / Debian​

We’ll add the popular Ondřej Surý PPA which provides the latest PHP packages.

sudo apt update
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.4 php8.4-cli php8.4-curl php8.4-mbstring php8.4-xml php8.4-zip php8.4-sqlite3

Verify the installation:

php -v

You should see PHP 8.4.x (cli) ....

Verify PHP Installation​

Regardless of your OS, run:

php -v

Expected output (truncated):

PHP 8.4.0 (cli) (built: ...) ( ZTS ... )
Copyright (c) The PHP Group
Zend Engine v4.4.0, Copyright (c) Zend Technologies
with Zend OPcache v8.4.0, ...

Also check that commonly needed extensions are loaded:

php -m

Look for curl, mbstring, openssl, pdo, and xml. This set covers almost every modern PHP project’s baseline needs.

Install Composer​

Composer is the de‑facto standard for managing libraries and autoloading in PHP. It’s essential from day one.

Windows​

Download and run the Composer-Setup.exe. The installer will locate your PHP installation automatically and add Composer to your PATH. Accept the defaults.

macOS / Linux​

Run the following commands in your terminal:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === file_get_contents('https://composer.github.io/installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Then move Composer to a system-wide location:

sudo mv composer.phar /usr/local/bin/composer

Verify:

composer --version

You should see something like Composer version 2.8.x 2026-....

Install Git​

Git tracks your source code history and is indispensable for collaborating or even just experimenting without fear.

Windows​

Download the installer from git-scm.com and run it. Select “Git from the command line and also from 3rd-party software” when asked about PATH adjustments. Accept the rest of the defaults.

macOS​

Git comes with Xcode Command Line Tools. If you haven’t installed them:

xcode-select --install

Or install via Homebrew for a newer version:

brew install git

Ubuntu / Debian​

sudo apt install git

Verify globally:

git --version

Install Visual Studio Code​

Visual Studio Code is a free, cross‑platform editor with a rich extension marketplace that turns it into a full PHP IDE.

Download the appropriate installer from code.visualstudio.com and follow the standard installation procedure.

After installation, launch VS Code.

Open the Extensions view (Ctrl+Shift+X / Cmd+Shift+X) and install the following:

ExtensionPurpose
PHP IntelephenseIntelligent PHP code completion, diagnostics, refactoring.
PHP DebugXdebug integration for step‑debugging inside VS Code.
EditorConfigHelps maintain consistent coding styles between editors.
DockerSyntax highlighting and management for Dockerfiles and Compose files.
GitLensSupercharges Git capabilities: blame, history, comparisons.
Markdown All in OneConvenient for writing documentation and notes.
Error LensInline error messages right next to your code.
Code Spell CheckerCatches spelling mistakes in comments and strings.

These extensions dramatically improve your daily development experience.

Configure Your PHP Workspace​

Create a dedicated project folder where all your PHP exercises and projects will live.

mkdir ~/php-workspace
cd ~/php-workspace

Initialize a Git repository to track your changes from the start:

git init

Now you have a clean workspace ready for PHP code.

Create Your First PHP File​

Inside ~/php-workspace, create a file named index.php:

<?php

echo "Hello, PHPDevPro!";

Run it with PHP’s built-in web server or via the CLI:

php index.php

You should see Hello, PHPDevPro! printed in the terminal.

For a quick web test, start the built-in development server:

php -S localhost:8000

Open http://localhost:8000 in your browser. You’ll see the same greeting. Press Ctrl+C to stop the server.

Create Your First Composer Project​

Composer manages your project’s metadata and dependencies. Initialize a new project inside your workspace:

cd ~/php-workspace
composer init

Answer the prompts (you can accept defaults for now). This creates a composer.json file.

Now generate the autoloader:

composer install

Your project structure now looks like:

php-workspace/
├── composer.json
├── composer.lock
├── index.php
└── vendor/
└── autoload.php

The vendor/autoload.php file is what you’ll include in your PHP scripts to use any installed libraries. You’ll learn much more about Composer in the Composer chapter.

Common Installation Problems​

  • “php” not recognized in terminal
    PATH is not set correctly. Restart your terminal after adding PHP to PATH. On Windows, make sure you opened a new PowerShell window. On macOS/Linux, run source ~/.zshrc or source ~/.bashrc.

  • Composer not found
    Run composer --version. If it fails, reinstall following the instructions above and ensure the Composer binary is in a directory listed in your PATH.

  • Permission denied on macOS/Linux
    You may need to prefix commands with sudo when moving files to system directories. Be careful with sudo and avoid running Composer globally as root—use the local Composer per project.

  • Multiple PHP versions
    Run which php (Linux/macOS) or where php (Windows) to see which executable is being used. If an older version is taking precedence, reorder your PATH entries or uninstall the old version.

  • Extensions missing
    If php -m doesn’t show curl, mbstring, etc., open your php.ini and uncomment (remove the ;) the corresponding extension= lines. On Linux, you may need to install the package, e.g., sudo apt install php8.4-curl.

  • Windows long path issues
    If you extract PHP deep inside a nested folder, you might hit the 260‑character path limit. Extract directly to C:\php to avoid this.

Best Practices​

  • Keep PHP updated – Use your OS package manager or Homebrew to regularly check for updates.
  • Always use Composer – Even for tiny projects, Composer provides autoloading and dependency management.
  • Git from day one – Initialize a Git repository in every project folder. Commit early, commit often.
  • Don’t edit vendor/ – Contents of the vendor directory are managed by Composer. Any manual changes will be overwritten.
  • Commit composer.json and composer.lock – But do not commit the vendor/ folder to version control. Add vendor/ to .gitignore.
  • Separate environments – The built‑in PHP server is great for development, but never use it in production. We’ll cover production‑grade setups in Runtime and Deployment.

What’s Next?​

You now have a fully functional PHP 8.4 development environment. It’s time to write real code and build your engineering foundation.

ArticleLink
Create Your First Modern PHP Project/getting-started/first-php-project/
PHP Language Fundamentals/foundations/php-language-fundamentals/
Composer Dependency Management/foundations/composer/
PHP Runtime Overview/runtime/php-runtime-overview/
PHP Ecosystem/ecosystem/

Frequently Asked Questions​

Do I need PHP 8.4?​

Using the latest stable version is strongly recommended. PHP 8.4 contains performance improvements, new syntax like property hooks, and better type safety. However, if your project requires 8.3, the setup process is virtually identical—just substitute the version number.

Should I install XAMPP or native PHP?​

XAMPP bundles Apache, MySQL, PHP, and Perl into one installer. It’s convenient for absolute beginners but often lags behind in PHP versions and makes it harder to learn command‑line tooling. We recommend a native PHP installation (as shown here) because it gives you full control and matches real production workflows. You can add a web server like Nginx later when needed.

Is Composer required?​

Yes. Composer is the foundation of modern PHP. It manages libraries, generates autoloaders, and handles project metadata. Even the simplest project benefits from using composer init.

Which editor is best for PHP?​

Visual Studio Code with PHP Intelephense offers the best balance of performance, features, and ecosystem. PhpStorm is another excellent choice if you prefer a full IDE, but it’s commercial. This guide uses VS Code because it’s free and light.

Can I use Docker instead?​

Absolutely. Docker provides an isolated environment that matches production. We’ll cover it in detail in Docker for PHP Development. For now, a native installation is fastest for learning the language itself.

How do I upgrade PHP later?​

  • Windows: download the new ZIP, overwrite your C:\php folder, and check php.ini for any new directives.
  • macOS: brew upgrade php@8.4.
  • Ubuntu: sudo apt update && sudo apt upgrade.
    Always run php -v and composer diagnose afterwards.

Why can’t my terminal find php?​

Your PATH is incorrect or you haven’t opened a new terminal after modifying it. Try opening a fresh terminal or command prompt. If the problem persists, double‑check the directory where PHP is installed and ensure that directory is correctly added to PATH.

Do I need Apache or Nginx for learning PHP?​

No. For local development and learning, PHP’s built‑in server (php -S localhost:8000) is more than adequate. You only need a full web server when you start setting up a production‑like environment.

Should I install Git before Composer?​

No, Composer and Git are independent. However, having Git installed is useful because Composer can clone repositories using Git. We recommend installing both.

What should I learn after installation?​

Follow the PHP Learning Roadmap which starts with Create Your First Modern PHP Project and then moves into the Foundations section.

Key Takeaways​

  • Install PHP 8.4 natively (not via all‑in‑one packages) for maximum control and a production‑matching experience.
  • Composer is non‑negotiable; it manages dependencies and autoloading for every professional PHP project.
  • Git and VS Code complete your toolkit, enabling version control and a first‑class editing experience.
  • Verify each installation with --version commands and test PHP with a simple index.php.
  • Common PATH and permission issues are easy to fix once you understand the underlying mechanics.

Conclusion​

You’ve built a solid, modern PHP development environment that will serve you throughout your entire engineering journey. The time you invest in getting this right now saves countless hours of frustration later.

With PHP 8.4, Composer, Git, and VS Code at your fingertips, you are fully equipped to start writing clean, professional backend code. Take the next step with the first project guide and turn your environment into a working application.

Welcome to modern PHP development. Let’s build.