Xdebug proxy service for debug your PHP code
We are currently in beta testing. At this point, we offer you a free trial of our service with a limit of 3 IDE keys per account. The beta stage will last at least until March 01, 2025
Please feel free to send us feedback on any bugs or feature requests using the contact form
A Xdebug Proxy is a tool designed to facilitate remote debugging with Xdebug in a situation where multiple developers need to connect to a single remote server for debugging purposes. It acts as an intermediary between the developers' IDEs (Integrated Development Environments) and the server where the PHP code is running.
Here's how it typically works:
In a standard setup without a proxy, Xdebug supports a single debugging connection at a time. However, in a team environment, multiple developers might need to debug simultaneously. A Xdebug Proxy allows for this by managing multiple debugging connections.
Each developer connects to the Xdebug Proxy and registers their IDE key (a unique identifier). The proxy then routes debugging sessions from the server to the correct developer's IDE based on this key.
Without a proxy, each developer might need to configure their local environment and the server to enable remote debugging, which can be complex and time-consuming. The proxy simplifies this by being the single point of connection.
It adds a layer of security, as the remote server does not need to be directly exposed to multiple clients for debugging purposes.
Overall, a Xdebug Proxy is particularly useful in complex development environments where multiple developers need to debug code on a remote server simultaneously. It streamlines the process and provides a more manageable and secure way of handling remote debugging sessions.
Xdebug is a popular debugging and profiling tool for PHP. It provides a range of features to improve the PHP development process, including:
Xdebug offers step-by-step code inspection, allowing developers to understand how their PHP code executes, which is especially helpful for finding bugs.
It enhances PHP's error display with stack traces, making it easier to trace the origin of errors and warnings.
Xdebug includes a profiler for PHP scripts, useful for identifying performance bottlenecks and optimizing code for better performance.
This feature is crucial for developers who perform test-driven development, as it shows which parts of the codebase are covered by tests.
Xdebug can be configured for remote debugging, allowing developers to debug scripts running on a different server.
You can set breakpoints in your code, which will pause execution at that point, letting you examine the state of your application at that moment.
During a debugging session, Xdebug allows you to inspect and modify variables.
Xdebug integrates with many popular PHP development tools and IDEs, making it a versatile choice for various development setups
It is highly configurable, allowing developers to adjust its behavior according to their specific needs.
Overall, Xdebug is an essential tool for PHP developers looking to improve the quality of their code, diagnose issues more effectively, and optimize performance.
Xdebug is a powerful tool for PHP developers, offering debugging and profiling capabilities that significantly enhance the development process. Installing Xdebug can vary depending on your operating system. This article provides a comprehensive guide on how to install the Xdebug extension across different operating systems, including Windows, macOS, and Linux.
Before proceeding with the installation, ensure you have:
php -v
in your terminal or command prompt.The process for Linux is similar to macOS, but package managers differ. For Debian-based systems (like Ubuntu), you would use apt
; for Red Hat-based systems, yum
or dnf
might be used.
sudo apt-get update
sudo apt-get install php
sudo apt-get install php-xdebug
php -v
.macOS users often use package managers like Homebrew for software installations. Here’s how to install Xdebug through Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install php
brew install xdebug
php -v
in the terminal to ensure Xdebug is installed.php -v
to find out your PHP version.php.ini
file, which is typically found in your PHP installation directory. Open it with a text editor and add the following line at the end. And replace "path\to\php_xdebug.dll"
with the actual path to the DLL file you downloaded.
zend_extension = "path\to\php_xdebug.dll"
php -v
in your command prompt. If Xdebug is installed correctly, you should see it mentioned in the output.After installing Xdebug, you need to configure it for using with XDebug.HOST. You can do this by adding specific Xdebug settings to your php.ini
file on Windows and MacOS or /etc/php/<version>/mods-available/xdebug.ini
on Debian-based systems.
xdebug.mode=debug
xdebug.discover_client_host = false
xdebug.client_host=xdebug.host
;Optionally. Uncomment line below if you want restrict usage for certain IDE keys only.
;xdebug.trigger_value=<YOUR_ACCOUNT_KEY>_alice,123ABC456MYACCOUNTKEY789QW_bob
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=xdebug.host
Consult the Xdebug documentation for a comprehensive list of settings.
Installing Xdebug can significantly improve your PHP development workflow by providing valuable debugging information and performance metrics. By following the steps outlined for your specific operating system, you should now have Xdebug installed and ready to enhance your development process.
Integrating Xdebug with PhpStorm enhances debugging capabilities, making it easier to track down bugs and optimize performance. This updated guide reflects the PhpStorm interface changes, ensuring you can configure Xdebug proxy settings efficiently for remote debugging sessions.
File > Settings
on Windows/Linux, or PhpStorm > Settings...
on macOS.PHP > Debug > DBGp Proxy
.IDE key
field.Host
: xdebug.host and Port
: 9001.OK
to save your settings.Before PhpStorm can listen for connections from the Xdebug proxy, you need to register your IDE with the proxy server. This process tells the proxy your IDE key and where to forward incoming debugging connections.
Just navigate to main menu Tools > DBGp Proxy > Register IDE
Activate listening for incoming debug connections by clicking on the Start Listening for PHP Debug Connections
icon in toolbar.
With the configuration complete, you're ready to debug:
Registering your IDE with the Xdebug proxy server is a critical step for remote debugging, ensuring that the proxy correctly routes debugging information to PhpStorm. By following these instructions, including the registration process, you can set up a robust remote debugging environment that leverages the power of Xdebug with PhpStorm, enhancing your development efficiency and problem-solving capabilities.
Visual Studio Code (VS Code) is a lightweight but powerful source code editor that runs on your desktop. It comes with built-in support for JavaScript, TypeScript, and Node.js, and has a rich ecosystem of extensions for other languages, including PHP. When combined with Xdebug, it provides a robust environment for debugging PHP applications. This guide will walk you through setting up VS Code to use Xdebug through a proxy, which is especially useful for remote debugging or working in environments where direct connection to Xdebug is not possible.
Ctrl+Shift+X
(Cmd+Shift+X
on MacOS).Ctrl+Shift+D
(Cmd+Shift+D
on MacOS). Click on "create a launch.json file", then select PHP. This creates a launch.json
file in the .vscode
folder of your workspace.launch.json
for Proxy Settings: Add or modify the configurations to include the pathMappings and port, according to your server setup. Here’s an example configuration:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug.HOST",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html": "${workspaceFolder}/src",
"/app": "${workspaceFolder}"
},
"proxy": {
"enable": true,
"host": "xdebug.host",
"port": 9001,
"key": "123ABC456MYACCOUNTKEY789QW_alice"
}
}
]
}
pathMappings
to match your server and local paths.
Setting up Visual Studio Code for use with an Xdebug proxy involves configuring both Xdebug to communicate through the proxy and VS Code to listen for connections from the proxy. This setup is invaluable for remote debugging or environments where direct connections to Xdebug are not feasible. By following these steps, you can leverage the powerful debugging features of Xdebug within the versatile and user-friendly VS Code editor, enhancing your PHP development workflow.