PHPStorm step-by-step setup for Fedora14 development via ssh on CentOS server +xdebug

Deployment/development environment outline:


- PHPStorm is running on my local developent workstation (10.0.0.111) (Fedora 14 GNU/Linux)
- Apache server is running on remote host (10.0.0.210) (CentOS 6.3)
- project files on local workstation  10.0.0.111  are delpoyed in /home/vleo/test_phpstorm/test
- phpstorm project is located in /home/vleo/test_phpstorm
- project files on server are deployed in /var/www/opencart/test
  files are: test.php, Page.php
- remote DocumentRoot is /var/www/opencart
- /var/www/opencart on remote host is accessed via sftp (sshd running on remote)

running phpinfo() on server, only xdebug relevant items:


configuration on host in /etc/php.d/xdebug.ini:

Here is step-by-step install procedure:

  1. toplevel PHPstorm screen
  2. select 'Web server is on remote host'
  3. specify project path
  4. specify (or create) remote server
  5. designate remote directory with project files
  6. select files to exclude from project
  7. exclude files result
  8. specify web path for the project (if it's not on httpd DocumentRoot)
  9. also exclude extra files - end up with needed files only in project
  10. enable listening for incoming xdebug connections - telephone handset symbol below 'Window' upper pulldown menu
  11. press selector below 'Run' and 'Tool' upper menu selection to add xdebug host, then press upper plus to add such a host
  12. specify remote host key, we use 'phpstorm-xdebug', then press add server ( '...' to the right of 'Servers' field)
  13. specify remote host IP and port 9000, press OK, then OK again
  14. now we're back at phpstorm project view, but we have remote debug system specified (host_10_0_0_210 below 'Tools', 'VCS' on upper menu
  15. open source code we want to debug, set breakpoing by clicking next to line number (you need to enable file line numbers to get same view as we have here)
  16. open web browswer, enter URL of your web site, but append ?XDEBUG_SESSION_START=phpstprm-xdebug
  17. your script will run under the debugger and you'll get the dialog asking to manually set mapping between your source file and it's web address (WHY? seems there is enough information to decude the correct mapping)
  18. then you'll finally stop in the debugger, on the source code line you've specified breakpoint for
  19. web browswer will show 'Connecting', that is because your script is stopped under the debugger and web page is not yet sent
  20. press continue and get to a file view w/o the debugger
  21. at that moment web browswer gets the page and show it


Here are the views for steps described above:
http://www.vleonov.com/nzhu

and I'm attaching PHP files, used for this test

Conclusion

  • xdebugger works well with PHPStorm
  • setup is not trivial (about 15 steps, mistake on each step may mess up the result)
  • PHPStorm has some deficiency in terms of matching remote URL of scripts executed with local sources, in spite of sufficient information set with 'Settings -> Deployment' dialog (see last 3 pictures at the URL above)


Attachment(s):
Page.php.zip
1 comment
Comment actions Permalink

Hi Vassili,

17. your script will run under the debugger and you'll get the dialog asking to manually set mapping between your source file and it's web address
(WHY? seems there is enough information to decude the correct mapping)

PHPStorm has some deficiency in terms of matching remote URL of scripts executed with local sources, in spite of sufficient information set with 'Settings -> Deployment' dialog (see last 3 pictures at the URL above)


Yes and No at the same time. And to have the same routine for all scenarios, the best solutions is to choose "No" (I'll explain below)

Up till this step you have provided only Deployment details (path mappings). For PHP debugging you have to provide separate mappings (Settings | PHP | Servers). Reasons:

1) "Deployment" and "PHP support" functionality is presented by 2 different plugins, which do not interact with each other that well as one of them simply can be turned off if desired so. Which means: you still should be able to debug remote code even if Deployment functionality ("Remote Hosts Access" plugin) is not available. If such settings would be stored in single place, the path mappings will not be available for debugger to match paths.

2) Deployment path not always equal to Debug path. Yep -- that is the biggest reason -- symbolic links and alikes. Thing is -- debugger works with final/real paths and not symbolic links.

For exampleYou may be deploying to /var/www/opencart but in reality it is just a symbolic link to /var/www/project-blabla . When you execute http://mysite.dev/index.php, web server will be using /var/www/opencart/index.php , but PHP/Xdebug (for example) will be working with real path, /var/www/project-blabla/index.php. As you can see you cannot gather this info from Deployment mappings -- without proper mappings breakpoints will not be hit.

Another often used scenario -- web root is where it is, but some libraries are located elsewhere (symbolic links again .. or just code accessing them directly at that path -- e.g. in shared libraries place, so multiple sites can use the same version of that library -- no need to update it for each site -- just once for all). This is of course, if you need to step into those libraries, which sometimes is required.

So ... Yes -- in your simple case it would be enough (to borrow path mappings from Deployment) but Not in more complicated scenarios.

16. open web browswer, enter URL of your web site, but append ?XDEBUG_SESSION_START=phpstprm-xdebug

Why? I mean -- not really necessary, since you have created Run/Debug configuration already (Run | Edit Configurations) -- you could just select it in that drop-down box on main toolbar and click on Debug button -- it will open URL in browser with required debug parameter in place. Of course -- you may want to debug not that particular page, but another one (e.g. which is one click away etc), then yes -- correct. But then -- I think using Bookmarklet or special browser extension to initiate is easier and more convenient.

13. specify remote host IP and port 9000, press OK, then OK again

Why port 9000 if your screenshots showing that you are using port 80 for connections (9000 is for xdebug, and it is setup at Settings | PHP | Debug | Xdebug). If you go to "Settings | PHP | Servers" (now, after executing all this configuration), you will see that you have 2 entries -- one that you have created yourself, and another once created automatically by PhpStorm when it asked you (in a popup dialog) to setup path mappings (during debug).


If you have not seen this article -- have a look (you can debug without specifying a single Run/Debug configuration). It should save few steps: http://confluence.jetbrains.com/display/WI/Zero-Configuration+debugging+with+PhpStorm+2.0

0

Please sign in to leave a comment.