Xdebug For Phpstorm
This section provides a handful selection of tutorials that will help you get started with PHP debugging in PhpStorm.
- Xdebug For Phpstorm
- Xdebug Phpstorm Docker
- Phpstorm Xdebug Docker
- Xdebug For Cli Phpstorm
- Configure Xdebug For Phpstorm
It looks like PhpStorm's checking script isn't fully updated yet, so it's recommending a confusing mixture of old and new settings. The most important changes are: The new xdebug.mode setting toggles a whole bunch of settings at once rather than having to remember the right combination. Some settings are simply no longer needed because of this.
Quick Start
Before proceeding with any of the debugging scenarios, you need to choose a debugging engine and install it in your PHP environment. These tutorials will guide you through the installation process:
With the debugging engine installed, you can start debugging by following the zero-configuration debugging approach:
- In this video I show you how to install Xdebug on Ubuntu and configure it to work with PhpStorm's Xdebug tools. NEVER type vardump again!For Magento 2 devel.
- Phpxdebug: 1 phpxdebugdefaultenable: 1 phpxdebugremoteconnectback: 0 phpideconfig: servername=phpstorm phpxdebugidekey: 'phpstorm' phpxdebugremotehost: 172.17.0.1 # linux If you enable these after you've created the PHP container, remember to restart the container so that xdebug is enabled and configured.
- Xdebug is an extension for PHP to assist with debugging and development. Makes development easier by allowing the developer to debug his code in a simple and quick way. How to install Xdebug. In this tutorial, we will be installing Xdebug on Windows 10, the steps are similar for any Windows version.
Choose and install the browser extension suitable for your browser.
On the PhpStorm toolbar, toggle to start listening for incoming PHP debug connections, or choose Run | Start Listening for PHP Debug Connections from the main menu.
Set a breakpoint in your code. Breakpoints can be set in the PHP context inside PHP, HTML, TWIG, BLADE, and files of other types. Line breakpoints can be set only on executable lines, but not on comments, declarations, or empty lines. For details on getting started with Twig and Blade debugging, refer to Debug Twig templates and Debug Blade templates.
Start the debugging session in the browser using the installed browser extension.
During a debugging session, examine the program state: see variable values, evaluate expressions, step through the program, and so on.
See Zero-configuration debugging for the detailed step-by-step instructions, and Advanced debugging scenarios for more debugging scenarios.
Debugging a PHP web application
Depending on your environment, you can debug your PHP Web application locally or remotely.
Local debugging | Remote debugging |
---|---|
The debugging engine and PhpStorm are running on the same machine. | The debugging engine is running on a remote environment (for example, a remote server or a virtual machine). |
Follow the Zero-configuration debugging procedure. |
|
To test direct connection, run the telnet host 9000
(for Xdebug) or the telnet host 10137
(for Zend Debugger) command on the remote server and ensure that connection is established. Here, host
is the IP address of the local machine PhpStorm is running on.
To check for opened inbound ports, you can use canyouseeme.org or a similar service.
Debugging a PHP CLI script
Depending on your environment, you can debug your PHP CLI script locally or remotely.
Local debugging | Remote debugging |
---|---|
The debugging engine and PhpStorm are running on the same machine. | The debugging engine is running on a remote environment (for example, a remote server or a virtual machine). |
Follow the Debug a PHP CLI script procedure. |
|
Besides running an entire application, you may want to run a PHPUnit or Behat test that covers a specific class, function or scenario, with the debugging engine attached. To learn how to do it, follow the Create a test configuration for a specific target procedure.
Troubleshooting
When using Xdebug or Zend Debugger with PhpStorm, some misconfiguration can prevent the debugger from working. In the Troubleshooting guide, you will find the description of some common issues and learn how to troubleshoot them.
Advanced debugging scenarios
The following topics will assist you in exploring the advanced debugging scenarios in PhpStorm:
Xdebug For Phpstorm
This article will show you step by step how to install and use Xdebug on Windows.
Xdebug Phpstorm Docker
Contents:
Resources:
Official Xdebug installation guide from JetBrains (really good)
What is Xdebug?
Xdebug is an extension for PHP to assist with debugging and development.
Why use Xdebug?
Makes development easier by allowing the developer to debug his code in a simple and quick way.
Phpstorm Xdebug Docker
How to install Xdebug
Xdebug For Cli Phpstorm
In this tutorial, we will be installing Xdebug on Windows 10, the steps are similar for any Windows version. You must have PHP installed on your system.
Configure Xdebug For Phpstorm
- Go here and install Xdebug:
- Run the following command in a terminal:
- Copy the output of that command and paste it in the Xdebug Wizard. Then click Analyze my phpinfo() output.
- Once analyzed, the result will tell if you have Xdebug installed or not, and which .dll file to download.
- Download the specified file from the step before. For me is: php_xdebug-2.6.0-7.2-vc15-nts-x86_64.dll
- Move the downloaded file to the /ext folder. This is the folder where PHP keeps all of its extensions and can be found under the folder where you have installed PHP. On mine, it is located in C:PHPext.
- Open php.ini file in an editor like Notepad, Notepad++ or Visual Code. This file is located within the folder where you installed PHP, C:PHPphp.ini for me.
- At the end of this file, add the following lines:
- Check if Xdebug has been installed by running the following command in a terminal:
The line that says ‘with Xdebug v2.7.0alpha1’ confirms that it has been installed correctly.
Copy file to ext directory