Download phpstorm remote debugging8/22/2023 A local VirtualBox VM running Ubuntu 16.04 Xenial with the latest docker-engine installed.You do not need to use the exact set up, but the configuration to follow assume that you are using this set up. The following describes my set up of the development environment. Using Docker in a VirtualBox setup either using docker-machine or an Ubuntu VM.Using Docker (with the official PHP image).This post assumes you have the following set up: This is because we are not integrating PhpStorm fully with Docker, we are merely using PhpStorm for debugging purposes. We will not be using the official Docker Support in PhpStorm. This post outlines the configuration needed to incorporate the debugging power of the PhpStorm IDE to your PHP based web app. However, these tools become difficult to use when you decide to include Docker in your workflow. These debugging tools are very useful in a local development environment, you can view the states of variables, indicate line breaks etc. ![]() When the debugger breaks on an error or Exception, PhpStorm can give us some additional information about the actual error.There are many tools that can be used for debugging when developing a web app using PHP. Do note that E_ERROR, E_PARSE and E_COMPILE_ERROR can’t be handled as they halt execution of the PHP engine: In this window we can specify custom Exception types we want to break on or make use of Warning, Notice or Deprecated to break on PHP error conditions instead. We can open the Breakpoints window ( Run | View Breakpoints…) and add the errors or Exceptions we want the debugger to break on. PHP Exception breakpoints do not require the Xdebug remote_mode to be set to jit. With them we can initiate the debugger at the start of the script and break on our own breakpoints or whenever an error or Exception of a given type occurs. Next to jit debugging, the latest PhpStorm 7.1 features PHP Exception Breakpoints. For that, Xdebug’s remote_mode setting has to be reverted to “ req”. Note that when jit debugging is enabled in php.ini, traditional debugging options using HTTP GET/POST variables will not work. If it is handled, the debugger will break at the first line of the catch block if there is one, or the finally block when using PHP 5.5: Here’s another example to illustrate where PhpStorm will break when an Exception has been thrown. The reason for that is PHP first has to run the erroneous code before it knows something is wrong. After kindly asking PhpStorm to listen for incoming debugger connections (from the toolbar or the Run | Start Listen for PHP Debug Connections menu), Xdebug will only connect to our IDE when an error occurs, such as this nice Division by zero which seems to have slipped into our code base:įrom the above screenshot we can also see that PhpStorm halts execution on the line right after the error condition. jit will start debugging only after an error or Exception occurs. req, the default one, will start a debugging session at the script start. The remote_mode setting for Xdebug specifies when the debug session will be initiated. It can be done in php.ini or dynamically, per script: ini_set(‘xdebug.remote_mode’, ‘jit’) Setting it to jit instead of the default ( req) will do. However, we can instruct Xdebug to connect only as soon as an error condition occurs, by using the xdebug.remote_mode setting. Meet Xdebug’s just-in-time (jit) mode and PHP Exception Breakpoints in PhpStorm!īy default, Xdebug will only connect to our IDE after we enable remote debugging and use a specific HTTP GET/POST variable to start the debugger. Or maybe we just want to run our code and only attach the debugger when an error occurs or an exception is thrown. In every project comes a moment where code stabilizes and we don’t want to keep the debugger attached to our code all the time.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |