Posts tagged 'netbeans'

Debugging two PHP projects in Netbeans at the same time

published on August 19, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I’m currently working on some Symfony2 bundles and I have one Netbeans project for the main Symfony2 app and one project for the bundle. The bundle files are completely separated from the app and they are just linked (ln -s) together. It works great, except for the case when I need to debug some part of the bundle’s code with Netbeans + xdebug. The debugger starts for the “main” project, which is the Symfony2 app, but setting breakpoints with Netbeans (y’know, by clicking the line number) for the bundle doesn’t really work, as those are in the other project and not in the debugged one, rendering the whole debugging useless.

The solution is pretty easy actually: instead of setting breakpoints with Netbeans, use xdebug_break() where you want the break to happen and it will happily be caught by the IDE. After the break happened use the “Step into” (F7) functionality to see what’s going on.

Debugging Zend Framework unit tests with Xdebug and NetBeans

published on July 24, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I’ve spent this weekend hacking on some unit tests for Zend\Dojo and I ran into an issue where I need Xdebug to, well, debug. Note, that this is not for debugging a Zend Framework application, but for debugging Zend Framework itself. I am using Netbeans + Xdebug to debug regular code, but debugging unit tests was something completely new for me. Turns out, it’s not entirely different from “regular” debugging.

Greatest help to figure out this was Raphael Dohms’ blog post “Debugging PHPUnit tests in Netbeans with Xdebug”. Almost worked out fine, but Netbeans complained about a missing index file and the autoload of files was… not really working. After a bit of poking around, the solution was to go to File -> Project Properties -> Run Configuration and set the “Index File” to /path/to/zend_framework_2/tests/_autoload.php - no more missing index file and the autoload works too!

Starting the debug session stays the same as explained in Raphael’s post: click “Debug project” (CTRL+F5), go to the terminal and just type something like:

robert@odin:~/www/zf2/tests$ /path/to/phpunit-debug Zend/Dojo/DojoTest.php

Netbeans will pick up the connection and debugging can start!

Happy hackin’!

Quick Netbeans tip - task filters

published on April 27, 2010.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I’m using Netbeans as my main IDE for PHP and Python projects for over a year now, yet only now I have stumbled upon this feature - creating filters for tasks that show up in the “Tasks” window (Ctrl+6 shortcut to show/hide the window).

To be honest, I wasn’t even using it (until now), cause, by default it shows all the todo-s and issues from all the files from the current project. This can produce a pretty big list if (like me) you have Zend Framework, Pear and other frameworks and libraries set on the include path for the project you’re working in, as the little @todo-s will show up from those files, too.

Filters to the rescue. On the “Tasks” window there’s that little icon of that whatever-it’s-called showed on the first image, where you can create and edit filters. I’ve created a simple one, which excludes todo-s from files that have “Zend” in their location and includes only from PHP files (second image).

Me likes this feature.

Tags: filters, ide, netbeans, tasks, tip.
Categories: Development, Software.
Robert Basic

Robert Basic

Software engineer, consultant, open source contributor.

Let's work together!

If you require outsourcing or consulting help on your projects, I'm available!

Robert Basic © 2008 — 2019
Get the feed