Symfony - Debugging with Eclipse

Installation and environment issues, mainly on 1.x but there's some 2.x here too.

Moderators: dwhittle, Ian

Symfony - Debugging with Eclipse

Postby armyofda12mnkeys » Wed Oct 13, 2010 9:24 pm

EDIT:solved... I'll add the code that fixed the Mapping needed to debug below in Red Bold... I think an Eclipse upgrade made previous way i defined mappings wrong?

I had setup a symfony debugging environment before and now it doesn't work.
Breakpoints do not work. Only way for me to debug is to set 'Break at First Line' option in debug configuration.
Not sure what i changed as I had this environment working until recently, not sure what has changed.

Anyway here are my steps (some recanted from memory as setup these projects few months ago):
The apache virtual host itself is:
Code: Select all
<VirtualHost 127.0.0.1:80>
  ServerName blah.localhost
  AddDefaultCharset UTF-8   
  DocumentRoot "C:\dev\workspace\blah\web"
  DirectoryIndex index.php index.html
  <Directory "C:\dev\workspace\blah\web">
    AllowOverride All
    Allow from All
  </Directory>
#got different versions of symfony libs in another folder so i can choose which common lib I want to use for web projects ... so i can just update the one Symfony 1.X code base
  Alias /sf "C:\dev\libs\symfony\symfony10\data\web\sf"
  <Directory "C:\dev\libs\symfony\symfony10\data\web\sf">
    AllowOverride All
    Allow from All
  </Directory> 
  ErrorLog "logs/blah.log"
</VirtualHost>

(also C:/windows/system32/drivers/etc/hosts file is set to point to blah.localhost to localhost):
127.0.0.1 blah.localhost

and to enable debugging i have in php.ini a reference to where the xdebug extension is, and also some settings:
php.ini has xdebug installed (or zend, right now I have xdebug enabled). phpinfo() confirms this...
Code: Select all
#Zend debugger ... uncomment below and comment xdebug if using Zend.
#zend_extension_ts="C:\dev\php\ext\ZendDebugger.dll"
#zend_debugger.allow_hosts=127.0.0.1
#zend_debugger.expose_remotely=always
#zend_debugger.connector_port = 10000

zend_extension_ts="C:\dev\php\ext\php_xdebug-2.0.5-5.2.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1;
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_log="C:\dev\temp\xdebug_remote_log.txt"
; profiler settings
; This will stop profiling process, and every time you wish to start profiling you must change it back to 1, and restart Apache.
xdebug.profiler_enable=0
xdebug.profiler_append=1
; can debug specific pages by adding to url: ?XDEBUG_PROFILE=1
xdebug.profiler_enable_trigger=1
;3 below shows what goes into function calls
xdebug.collect_params = 3
;3 output dirs ... for Win/KCacheGrind to analyze php code
xdebug.profiler_output_dir="C:\dev\temp\xdebug"
xdebug.profiler_output_name="xdebug-%t.cachegrind.out.txt"


I have Eclipse PDT (php plugins included) installed.
Eclipse also has the debugger plugins installed (think came default with Zend, had to install Xdebug. u can google that if want to use Xdebug)...

I setup a new php project in Eclipse called blah (symfony directory structure in there like c:/dev/workspace/blah/web ,etc ).
It was in fact checked out of SVN.
Project is put into the folder c:/dev/workspace/blah


Under Eclipse Preferences->PHP->Debug->Installed Debuggers, i have Zend Debugger port 10000 and Xdebug Port 9000 (i switch between them sometimes by keeping one I want uncommented in php.ini ... I had them both working at some point for symfony debugging. For this example, just trying to get my preferred debugger Xdebug to work, although problem of breakpoints now working occurs for both debuggers).
In Eclipse Preferences->PHP->PHP Servers, I called the name of server: 'Blah.Server' and for the 'Enter the url that points to document root of this server' setting, i had: 'http://blah.localhost'
In the Path Mappings, not sure what to put here ... before I think had for 'Path on server': 'c:/dev/workspace/blah' and Local Path('Path in Workspace') set to /blah.
This may be the main issue, as i heard if breakpoints don't work, the path mappings might be to blame ... although this is a pretty simple example with no remote stuff, just localhost (although it is a lil' advanced eclipse environment as the front controller frontend_dev.php served out of web/ folder).
EDIT: I needed this mapping... 'Path on Server' set to '/' and Local Path('Path in Workspace') set to '/blah/web'

The eclipse Debug configuration,
points to 'Server Debugger': 'XDebug'
PHP Server points to the 'Blah.Server' one i setup.

Has 'Break at First Line' unchecked as i dont want to step through everything...

File: is 'frontend_dev.php/mymodule/myaction/param_id/45'
Url is: 'http://blah.localhost/' and '/frontend_dev.php/mymodule/myaction/param_id/45'
In Advanced, I have 'Open in Browser' checked and 'Debug All Pages' option selected, cause I want to debug my breakpoints which are on a page after a POST/submit. (so it should look for break points at all times while I'm surfing the site).

Anyway, once I click Debug, It goes to the url 'http://blah.localhost/frontend_dev.php/mymodule/myaction/param_id/45' correctly ... it doesnt stop at any of my breakpoints anymore... If i change that 'Break at First Line' and re-debug, it starts debugging... But obviously I don't want to click a thousand times just to get to where my break point is.

I think possibly the Path Mapping setting is wrong. Although it is the same as when debugging was working...
So in summary:
Apache-virtual-hosted out of: C:\dev\workspace\blah\web
Symfony/Eclipse Workspace: C:\dev\workspace\blah
Url to reach site (serves the website out of the workspace): http://blah.localhost

If anyone has an idea of what the Server Mapping should be in my example, or anything else wrong, let me know :).
Thanks!

If i figure out whats wrong, i'll post here as there aren't many Symfony+Eclipse+Debugging articles.
armyofda12mnkeys
Junior Member
 
Posts: 10
Joined: Tue Nov 10, 2009 6:47 pm

Return to Installation and setup

Who is online

Users browsing this forum: No registered users and 1 guest