A Visual Studio Code extension to run PHP files on a XAMPP local server.
- Open
.php
or.html
files in the default browser.
- XAMPP installed and running.
- Visual Studio Code installed.
- Open Visual Studio Code.
- Open the Extensions View by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing
Ctrl+Shift+X
. - Search for
php-xampp-runner
in the Extensions view search bar. - Click Install next to the extension in the search results.
- Reload VSCode if prompted.
-
Set PHP Executable Path:
- Open VSCode settings (
Ctrl+,
). - Search for
php.executablePath
and set it to the path of your PHP executable, typicallyC:\\xampp\\php\\php.exe
.
- Open VSCode settings (
-
Configure XDebug (Optional, for Debugging):
- Open
php.ini
(located inC:\xampp\php\php.ini
). - Add the following lines:
[XDebug] zend_extension = "C:\xampp\php\ext\php_xdebug.dll" xdebug.mode = debug xdebug.start_with_request = yes xdebug.client_port = 9003
- Open
-
Open in Default Browser:
- Right-click on a
.php
or.html
file in the VSCode explorer. - Select
Open in Default Browser
from the context menu. - Ensure your XAMPP server is running and the document root is set to your workspace folder.
- Right-click on a
-
Place Your Project Folder in
htdocs
:- Move your project folder inside the
htdocs
directory of your XAMPP installation. For example, if your project folder is namedmy_project
, it should be located atC:\xampp\htdocs\my_project
. - This ensures that your PHP files are accessible via
http://localhost/your_project_folder/your_file.php
.
- Move your project folder inside the
This project is licensed under the MIT License - see the LICENSE file for details.
- XAMPP
- Visual Studio Code
- Node.js
Feel free to contribute or report issues to the repository. We're always looking to improve and expand the examples provided. https://github.com/tirotir-ir/php-xampp-runner.git
Happy coding with PHP!