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:
- Download it from herd.laravel.com
- Run the installer
- 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
Option 1: Laravel Herd (Recommended)
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 mysqlorbrew 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.
