How to run php locally using VS Code (Windows)
1. Install the following VS code extensions
- PHP: https://marketplace.visualstudio.com/items?itemName=DEVSENSE.phptools-vscode
- PHP Intelephense: https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client
- PHP Server https://marketplace.visualstudio.com/items?itemName=brapifra.phpserver
2. Download php
https://www.php.net/downloads.php
You will find php.exe
inside the downloaded folder.
3. Add php path to Windows Environment Variables setting
3.1 In Windows setting, search Environment… in the setting
3.2 In User varaibles for this account, click Path
, then Edit...
3.3 In the pop up window, click New
, then add the folder path of php.exe
4. Add the php.exe path in VS code setting
In the setting.json
of VS code, add the following line (change the path to your php.exe
path)
Code
"php.executablePath": "C:\\Users\\username\\Desktop\\Tools\\php\\php.exe", |
5. Done! You will find PHP Server: Serve project
options when you right click on php file.
Reference
- Youtube - How to Run PHP Using Visual Studio Code 2023 | Programming Guru
- PHP Programming with Visual Studio Code