Project-Id-Version: Trac 0.12
Report-Msgid-Bugs-To: trac-dev@googlegroups.com
POT-Creation-Date: 2008-01-30 09:20+0100
PO-Revision-Date: 2010-07-19 23:05+0200
Last-Translator: Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
Language-Team: en_US <trac-dev@googlegroups.com>
Plural-Forms: nplurals=2; plural=(n != 1)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Generated-By: Babel 0.9.6

Warning: Can't synchronize with repository "(default)" (Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? ). Look in the Trac log for more information.
Last modified 5 years ago Last modified on 09/18/12 16:27:41

Following instructions gives you a small HowTo for debugging phTagr code with Netbeans 7.2 and Xdebug on Ubuntu 12.04

If you like to contribute some code to the phtagr project it is recommended to use a IDE with debugging support. Netbeans IDE is a great and free IDE with a good PHP language support. Combined with the PHP debugger and profiler Xdebug you can execute your code line by line and inspect variables which makes changes and errors easy to handle.

Requirements - Assumptions

  • You have some (php) programming skills
  • You installed and configured phtagr on your local web server like apache
  • You use phtagr source from phtagr's git repository

Install Netbeans and Xdebug

  • Download Netbeans 7.2 for PHP from http://netbeans.org/downloads/index.html
    http://demo.phtagr.org/media/thumb/396
    $ chmod 755 netbeans-7.2-ml-php-linux.sh
    $ ./netbeans-7.2-ml-php-linux.sh
    
    and follow the installation wizard (windows like). For detailed installation instruction visit netbeans.
  • Install xdebug via sudo apt-get install php5-xdebug. By default xdebug has a configuration file at /etc/php5/conf.d/xdebug.ini.

Create project

  • Start netbeans (e.g. run /home/sebastian/netbeans-7.2/bin/netbeans if you installed netbeans in /home/sebastian/netbeans-7.2). I like to run netbeans with Metall Look & Feel which has a smaller system font: /home/sebastian/netbeans-7.2/bin/netbeans --laf javax.swing.plaf.metal.MetalLookAndFeel
  • Create a new project via menu File -> New Project
  • Select PHP Application with existing Source. Confirm by clicking Next
    http://demo.phtagr.org/media/thumb/397
  • Enter your php git repository (e.g. /var/www/tests/phtagr), the project name. Confirm by clicking Next
    http://demo.phtagr.org/media/thumb/398
  • Enter the Project URL. At my machine /var/www is Apache's web root so http://localhost/tests/phtagr is the correct Project URL. At Index File enter webroot/index.php. Netbeans requires a real file and the main index file of phtagr is in webroot/index.php. Confirm by clicking Next
    http://demo.phtagr.org/media/thumb/399
  • Ensure at Menu Tools -> Options -> PHP -> Debugging that Stop at First line is disabled.
    http://demo.phtagr.org/media/thumb/400

Debug phtagr

  • Run Debug Project (shortcut Ctrl+F5). At the first page phtagr will report an error. But this is necessary to set the correct debug cookie for xdebug. Now you can use your phtagr installation and enter Project URL http://localhost/tests/phtagr.
    http://demo.phtagr.org/media/thumb/401
  • Use breakpoints to intercept the execution of php script. E.g. set a break point at Controller/AppController.php to function beforeFilter function but clicking on a line number. If you reload the page in your browser by hitting F5, netbeans will stop at your breakpoint line.
    http://demo.phtagr.org/media/thumb/402 http://demo.phtagr.org/media/thumb/403

Shortcuts

  • Ctrl+F5 - Start debugger
  • F8 - Step Over
  • F7 - Step Into
  • Ctrl+F7 - Step Out
  • F5 - Continue