We implement your business idea

Main menu

Monthly Archives: September 2010

XDebug is a free PHP extension to debug variables of your applications. Combined with Netbeans for PHP debug features (break points, variable watching and flow execution navigation, see screenshot on the left), it allows to have a complete debug environment.

What it’s really interesting is the possibility to place breakpoints in any file, even though not called directly in the local URL. That is required when working with web applications with URL routing/rewriting sudh as MVC applications (Zend Framework, Symfony etc..) where the PHP code in a controller action does not match with its path in the local URL.

Here are the easy steps to follow in order to configure Xdebug for Linux Ubuntu 10.04 LTS. I’ll write the full commands to make it easier by copy & paste.

-) download the xdebug extension

sudo apt-get install php5-xdebug

-) check where the extension is installed

sudo find /usr/lib/php5 | grep xdebug

-) open the php.ini file (inside apache)

sudo vim /etc/php5/apache2/php.ini

and add these lines at the end of the file (replace with the right module path)

(*): Xdebug is unstable with this options, however I found it very useful and enough stable for my purposes. It’s possible that Netbeans crashes with the current version, restart it in case.

5) Netbeans: right click on the project ->properties->Run configuration -> run as local website. Insert the (virtualhost) local URL. Do not insert any index file if the application uses URL routing, or Netbeans will launch the relative script path in the URL.

6) Netbeans: place your breakpoints by clicking on the line number, then start the debug (Under Debug->debug or Ctrl+F5). Netbeans will open the browser at the local URL, and when reaching the breakpoitns, netbeans will show a red icon on the line.
Depending on the browser, the focus will return to Netbeans (go manually if it does not).
Select the code / expression to watch/evaluate. Netbeans will show a baloon tip with the value. Alternatively, right click and select “new watch” to have the expression and the values appearing in the debug panel.
Use F5 to go to the next breakpoint, F7/F8 to step into/over.

As mentioned, Xdebug is unstable with the option set in the step 4. If watching some expressions crashes netbeans, use the “new watch” option instead.

JAVA developers sometimes tend to look down on other developers, including PHP developers. I think that is mainly due to ignorance of the current state of things and fear of seeing a competing technology growing so fast and being adopted more and more for a wide range of applications on the web.

“You can safely say that while PHP is easy to learn, it is more difﬁcult to truly master the language.

If we compare this to a language such as Java, we notice that Java has a ’natural barrier’; programming Java takes a certain amount of programming skill, so it is not a language that anyone can easily learn. This means that, even though the best PHP programmers can compete with the best Java programmers, the least skilled Java developer is probably still a better programmer than the least skilled PHP developer.

The range between high and low quality is simply bigger for PHP. This is one of the reasons why PHP sometimes has a negative image; PHP is for hobbyists and not to be taken seriously. But this is not the case; it simply means that you need to be careful what software you use and who you hire as a developer”.