Remote debugging PHP from phpStorm

Despite all the documentation out there, it seemed to take me longer than it should. Although in hindsight, it could have been working originally as phpStorm's indicator that it's debugging is subtle.

Debug session within phpStorm

Two articles to get you started:

To setup follow do the following:
  1. For chrome (probably the easiest), install this plugin: Chrome Plugin
  2. Configure the plugin and select phpStorm as your IDE.
  3. Next sign onto your remote server and enable xdebug module
    1. for cPanel, click select php version (only 5.4 and 5.5 supported)
    2. update version
    3. check the xdebug module
    4. click update
  4. Edit the php.ini, e.g. for cPanel, edit or create: /home/[username]/public_html/.user.ini
    ; Settings for xdebug
    module was already loaded on this machine:
    ; zend_extension=/opt/alt/php54/usr/lib64/php/modules/xdebug.so
    xdebug.remote_host=[your modems IP address]
    xdebug.remote_port=[a port forwarded through your modem to firewall, e.g. 9800]
    xdebug.remote_enable=1
    
  5. Setup phpStorm's port:
    Settings->Languages & Frameworks-->PHP-->Debug Xdebug port = [remote_port] set above
  6. Setup phpStorm remote debug settings:
    1. Run --> Edit configurations
    2. Add --> PHP Remote Debug
    3. Give it a name
    4. Ide key: "PhpStorm"
    5. Servers (select or add via the "...")
      1. Host: your remote server host
      2. Port: http port usually 80
      3. Debugger: xdebug
      4. Check "use path mappings"
      5. Setup any mappings
      6. Click validate
      7. Click close
    6. Click ok
  7. Run --> Start listening for PHP Debug Connections
  8. In the browser, click the debug icon in the address bar and select debug
  9. visit your sites URL
    You may need to go to the site first, the select debug, then refresh the page.
Note: .user.ini is cached by apache, so it may not work instantly.
When it works the page won't seem to load and in phpStorm the debugger tab should show a clickable green arrow ("Resume Program Execution") and it should show the current frame & variables.

I went through a couple of settings to get here so I may have missed a little tweak along the way.

Profiler

These settings were taken from: Diagnosing slow PHP execution with Xdebug and KCachegrind.
/home/[username]/public_html/.user.ini
; Settings for xdebug
; module was already loaded:
; zend_extension=/opt/alt/php54/usr/lib64/php/modules/xdebug.so
xdebug.profiler_output_dir=/home/[username]/php
xdebug.profiler_append=On
xdebug.profiler_enable_trigger=On
xdebug.profiler_output_name="%R-%u.trace"
xdebug.trace_options=1
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.collect_vars=0
xdebug.profiler_enable=0
The relevant .trace file can be downloaded and loaded into phpStorm via: Tools->Analyse Xdebug Profiler Snapshot.
See Analyzing Xdebug Profiling Data for more information.

Comments

  1. PhpStorm gives rich and keen govern manager

    ReplyDelete
  2. code, run unit-tests or offer to investigate that is aesthetic. PhpStorm gives rich and keen govern manager for PHP with grammar highlighting, broadened code arranging setup, on-the-fly blunder checking, and control culmination that is shrewd. PhpStorm 2017, discharged on March 23rd, 2017, is only a fresh out of the plastic new

    ReplyDelete
  3. I like to use and recommend Codelobster for it

    ReplyDelete
  4. It’s necessary to notice the difference between accessing a geo-blocked however authorized site and a banned site or one that facilitates illegal playing exercise. For example, we implore you to not use a VPN to entry playing websites in nations such as the UAE the place playing is illegal the law|is unlawful} and could land you severe trouble|in deep trouble} with the authorities. The goal of this examine was to handle latest calls to disentangle problematic versus non-problematic intensive involvement in cell playing . While not the be-all and end-all of a great on line casino, offering great welcome bonuses and rewards does go a 카지노 사이트 great distance in serving to new players decide to hitch a casino’s ranks. Bonuses and rewards are an internet casino’s way of incentivizing its players and constructing customer loyalty.

    ReplyDelete

Post a Comment