With the above settings and the Chrome helper, you can now step through PHP code at breakpoints set in the IDE. To simplify this, Chrome has an extension called Xdebug helper that let’s you toggle setting this cookie or not. To trigger debugging, it’s necessary to send a special cookie along with each page request you wish to debug: XDEBUG_SESSION=PHPSTORM To connect over an SSH tunnel, here is a guide from the makers of PhpStorm: Remote debugging in PhpStorm via SSH.įirst, you must tell PhpStorm to listen for Xdebug connections by clicking the “phone” icon like so: Enable Xdebug listening in PhpStorm On a development box it’s sufficient for the server to connect back to port 9000 on the IDE over HTTP. Essentially, you want to set the Xdebug IDE port to 9000 and the IDE key to PHPSTORM. There are a few places settings need to be set, so I defer to their help pages. JetBrains, the maker of PhpStorm, has detailed instructions on configuring Xdebug in their IDE. Setting the Debugger Configuration in PhpStorm Set PhpStorm to listen to Xdebug on port 9000 Restart Apache with apachectl restart or systemctl restart rvice (CentOS 7), or /etc/init.d/apache2 restart on Debian. If enabled, the xdebug.remote_host setting is ignored and Xdebug will try to connect to the client that made the HTTP request. Type: boolean, Default value: 0, Introduced in Xdebug > 2.1 If you are wondering why xdebug.remote_host is commented out above, here is an interesting point from the official docs that says why you can safely omit it: It’s just a gotcha if you find that no profiling logs are being written. This shouldn’t be a problem out of the box. You may want to ensure the write permissions are set to allow Xdebug to write to “/tmp/xdebug/”. I’ve found that if you are using WinCacheGrind on Windows, the profiler output name should start with “cachegrind” instead of “callgrind” because WinCacheGrind only recognizes one type of file. Xdebug.profiler_output_dir = "/tmp/xdebug/" Xdebug.profiler_output_name = "cachegrind.out.%t-%s" See the note below about this Xdebug.profiler_enable_trigger = On Profiling activated when requested by the GET parameter Xdebug.profiler_enable = Off Profiling not activated by default Xdebug.remote_addr_header = "HTTP_X_XDEBUG_REMOTE_ADDRESS" See the bonus section at the very bottom for details on using this Select a connect-back IP from the $_SERVER value set in a custom header Xdebug.idekey = "PHPSTORM" The IDE key which should match the XDEBUG_SESSION cookie value Xdebug.remote_port = 9000 Port on the IDE to connect back to. Xdebug.remote_connect_back = On Use a special $_SERVER variable to get the remote address xdebug.remote_host = "localhost" This is unused if the next setting is 'On' Xdebug.remote_autostart = Off Only start xdebug on demand, not on every request
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |