First step is to modify the php.ini file on the server. You can do this in Webmin. In the System menu press PHP Configuration. On the row for "Configuration for mod_php" press Edit Manually to open the file for editing.
Then add a configuration section for Xdebug, as follows:
[xdebug] xdebug.mode=develop,debug xdebug.discover_client_host=1 xdebug.client_port = 9003 xdebug.start_with_request=yes
After saving this change you will need to restart the Apache Webserver. This can be done in Webmin. Press Apache Webserver in the Servers menu and then press the apply changes icon button near the top right corner.
Then start VS Code and add the extensions PHP Extension Pack by Xdebug which includes PHP Debug and PHP IntelliSense and SFTP by Natizyskunk.
You need PHP on your workstation for these extensions to work, so download it from windows.php.net. The LAMP stack currently includes PHP 7.4 so I downloaded PHP 7.4.32 NTS Windows 64-bit. Once downloaded and uncompressed move it to your preferred location, you then need to tell the extensions the path to php.exe with the following three settings in settings.json (use your own path, not mine and ensure php.exe is included):
"php.executablePath": "D:\\Documents\\php-7.4.32-nts-Win32-vc15-x64\\php.exe", "php.debug.executablePath": "D:\\Documents\\php-7.4.32-nts-Win32-vc15-x64\\php.exe", "php.validate.executablePath": "D:\\Documents\\php-7.4.32-nts-Win32-vc15-x64\\php.exe"
You can now configure SFTP. Press Ctrl+Shift+P to bring up the command prompt and type
SFTP: config
. You can then enter a configuration similar to the following, using your website details, and FTP user and password.{ "name": "My Website", "host": "mywebsite.local", "protocol": "sftp", "port": 22, "username": "mywebsite", "password": "abc123", "remotePath": "/var/mywebsite", "uploadOnSave": false, "useTempFile": false, "openSsh": false }
Next configure the debug settings.
{ "name": "Listen for Xdebug", "type": "php", "request": "launch", "port": 9003, "pathMappings": { "/var/mywebsite": "${workspaceFolder}/" } }
You are now ready to debug. Press F5 to start listening for Xdebug connections and set breakpoints where needed.
If you need to set up URL rewriting, see my next post How to enable URL rewriting using the Turnkey Linux LAMP stack.
Rate this post:
Comments
There are no comments yet. Be the first to leave a comment!