PHP
Setting up VS Code
Install PHP and XDebug
First install the software. This was done in the WSL
sudo apt install -y php8.5 php8.5-cli php8.5-common php8.5-mbstring php8.5-xml php8.5-curl php8.5-mysql
sudo apt install php-xdebug
Check your php now has Debug. You should see Xdebug listed
php -v
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.5.3, Copyright (c) Zend Technologies
with Xdebug v3.5.0, Copyright (c) 2002-2025, by Derick Rethans
with Zend OPcache v8.5.3, Copyright (c), by Zend Technologies
Change Your Xdebug.ini
Find you wsl ip with
hostname -I
172.28.58.213
Find your xdebug.ini
php -i | grep 'xdebug.ini'
/etc/php/8.5/cli/conf.d/20-xdebug.ini,
Now amend your xdebug.ini to have this and remember to use your ip
zend_extension=xdebug.so
xdebug.mode = develop,debug
#xdebug.start_with_request = trigger
xdebug.start_with_request = yes
xdebug.client_port = 9003
xdebug.client_host = 172.28.58.213
Set up VS Code
Create a launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/": "${workspaceFolder}"
}
}
]
}
Install extension Php Debug by Xdebug
Running in VS Code
For me I simply pressed F5 to run the launch.json and ran the code with
php -S localhost:1701
Other Stuff I installed
We need to install
sudo apt install php-cli composer php-xml
You will need to set up php-cs-fixer first. Extensions suggested are
- PHP Intelephense
- PHP Getters & Setters
- PHP debug
- PHP CS Fixer
- Twig Language 2
- SQLTools
Creating Project With Composer
To create a project you need to run the following. The only tricky bit is the name where they want vendor/name e.g. bibble/test
composer init