Setting Up PHP the Right Way in 2026

matt
Matthew Gros · Jan 5, 2026

TLDR

Get PHP 8.3+, install Composer, set up Xdebug for debugging, use Herd or Valet for local sites, configure VS Code properly.

Setting Up PHP the Right Way in 2026

Stop Following Outdated Guides

Half the PHP setup tutorials online are from 2018. Things have changed. XAMPP and MAMP are mostly unnecessary now. Here's what to actually do.

Getting PHP Installed

Mac Users

Homebrew makes this painless:

brew install php

That's it. You now have the latest PHP. Check it worked:

php -v

You should see PHP 8.3 or higher.

Windows Users

Forget XAMPP. Laravel Herd exists now and it's way better:

  1. Download it from herd.laravel.com
  2. Run the installer
  3. Done - you have PHP, Composer, and Node ready to go

Linux (Ubuntu)

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.3 php8.3-mbstring php8.3-xml php8.3-curl php8.3-mysql

Composer is Non-Negotiable

Every PHP project uses Composer for dependencies. Install it:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"

Test it:

composer --version

Extensions You Actually Need

Frameworks need certain extensions. Check what you have:

php -m

The important ones:

  • mbstring - handles non-ASCII text
  • xml - for parsing XML (lots of stuff uses this internally)
  • curl - making HTTP requests
  • pdo_mysql or pdo_pgsql - database connections
  • zip - composer needs this

Missing one? On Ubuntu it's usually apt install php8.3-extensionname.

Debugging with Xdebug

Print statements are fine for quick debugging. But when you're stuck on something complex, step debugging is invaluable.

Install Xdebug:

pecl install xdebug

Add this to your php.ini:

[xdebug]
zend_extension=xdebug
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.client_port=9003

Not sure where your php.ini is? Run php --ini.

Editor Setup

VS Code works great for PHP if you configure it right.

Install these extensions:

  • PHP Intelephense - the good autocomplete (disable the built-in PHP support)
  • PHP Debug - connects to Xdebug

In your VS Code settings, tell Intelephense which PHP version you're using:

{
    "intelephense.environment.phpVersion": "8.3.0"
}

Running Your Code Locally

If you installed Herd, just put your projects in the Herd folder. Access them at projectname.test. It handles SSL too.

Option 2: PHP's Built-in Server

For quick testing:

cd your-project
php -S localhost:8000 -t public

Visit localhost:8000 in your browser.

Option 3: Sail (Docker)

If you want containers:

composer require laravel/sail --dev
php artisan sail:install
./vendor/bin/sail up

I find this slower for day-to-day work, but some people prefer the isolation.

What About Databases?

Herd includes DBngin for database management. Otherwise:

  • Mac: brew install mysql or brew install postgresql
  • Windows: Download the installer from the database's website
  • Linux: apt install mysql-server

TablePlus or DBeaver are good GUI tools for working with databases.

You're Ready

That's genuinely all you need. PHP and Composer are installed, you have a local server, your editor has autocomplete, and you can debug when things go wrong.

Start building something.

About the Author

matt

I build and ship automation-driven products using Laravel and modern frontend stacks (Vue/React), with a focus on scalability, measurable outcomes, and tight user experience. I’m based in Toronto, have 13+ years in PHP, and I also hold a pilot’s license. I enjoy working on new tech projects and generally exploring new technology.