I’ve been tinkering with dumping PHP objects, and have found myself constantly running into a brick wall. The output from print_r and friends is fine in some contexts, but for larger structures, it would be nice to tidy the output up a bit and wrap it in some HTML.
However, these functions have a certain privilege in that they can access private/protected variables. This is not something that can be circumvented in plain PHP (save through some exotic extensions, which I’d rather not rely on). It seems that 5.3.0 may introduce a functionality in the Reflection API, but nobody knows when 5.3.0 will be out.
Zend Studio for Eclipse is a commercial edition of Eclipse plus the PDT plugin and various other additions. Unfortunately Zend decided to disable the Xdebug support of the Eclipse PDT plugin. Nonetheless if you'd like to use Xdebug for debugging your PHP scripts, follow these simple steps to restore the Xdebug functionality of Eclipse.
While PHP-developing it sometimes is just too tedious to do those 'add a echo here and there, then reload and search the echoed strings on the screen'-loops. So I searched for a debugger for my favourite editor emacs. After a lengthy install procedure I finally got it running: With geben on emacs you can debug PHP (step through and evaluate expressions)
Most of the PHP developers debug php code in their local machine just by trial and error using “print_r”,”var_dump” and “echo”. They dont write unit tests or follow any advanced debugger like xdebug. But the problem of using these methods is you cannot fool proof your code and their might be some bugs still present in your code. Lets see how can we debug our code more effectively getting more information from the php interpreter itself. There is a nice function called debug_backtrace() is available in PHP to trace the root of an error. As the name implies, you can trace the execution of you code which produces the error. Have a look at the following code.
Web developers who wish to use their time as efficiently as possible, should consider using an integrated development environment (IDE), if they are not already doing so. Just as the name suggests, a typical IDE provides the developer with an integrated suite of programming products, including an editor with multi-file editing, multiple undo and redo, local and global search and replace, stream and paragraph text selection, code-folding, multi-line tabbing, automatic creation and coloring of matching braces, intelligent indenting and outdenting of code, and more.
For the majority of experienced PHP developers, Zend Studio is considered the top-of-the-line PHP IDE. The product is put out by Zend, a company heavily involved with PHP, dating back to 1997. In fact, they created and contributed PHP's execution engine, the Zend Engine.
In this tutorial, we will explore how to use the latest update of Zend Studio for debugging PHP scripts. But first, we will get an overview of the product, its various editions, the system requirements for running it, and other installation considerations.
In March I will start to give a lecture on web programming at the University of Applied Sciences Rosenheim where I’ll be using PHP for practical application. This week I started to setup a Debian-based (Etch) web-server with PHP 5.2 in a virtual-machine with VMWare. Part of this setup was getting XDebug2 integrated. It’s really awesome and my students definitely need to learn about it. Shame on me, because I haven’t written Derick a postcard, yet.
Xdebug is one of the best debugger and profiler for php (maybe the only good one in open source :). The only problem is its lack of dedicated client (there is some work being done for a client but it targets only windows for now), however there is many plugins for many IDE or editors like Eclipse PDT or weaverslave and even for my favourite editor, Vim.
The vim plugin I will use here has been originally written by Seung Woo Shin and modified/improved by Sam Ghods. I find Sam's version less noisy and seems to work better. As far as I rembember it is also included in Andrei's vim script (I don't have it at hand, but check the Andrei's talk about php and vim, the url should be in there)
Welcome to the second installment of our five-part series of articles on xdebug, the PHP developer's swiss army knife extension. The installation of xdebug and its basic features were covered last week. This week, we will explore the tracing feature of xdebug.
As programs, especially object-oriented ones, become more and more complex, the individual code blocks become smaller and smaller. Small code blocks make a program easier to maintain, since changes and additions can be introduced without changing existing code. If you look at an object-oriented PHP program for the first time, however, it seems that the program never does any actual work, but just comprises of a seemingly endless series of delegations.
Though it may sound awkward, this is a sign of quality of object-oriented code. Each piece of code should do exactly one thing and different concerns should be separated. As a rule of thumb, the source code of one method should fit on the screen without scrolling.
In an effort to switch away from Zend Studio I have been trying out Komodo (again), as I have no desire to be co-erced into Eclipse (and whilst Zend currently is promising to support Zend Studio, I think it's pretty obvious that they will be moving entire to Zend Studio for Eclipse entirely before too long).
I have tried to use Komodo several times in the past, but have always found it not quite up-to par with Zend Studio.
I tried to review it again with 4.0, however it crashed repeatedly on Linux with my large project (75MB+), so I was never able to get a comprehensive enough feel such that I could do so. However, many people have extolled the virtues of Komodo and so I decided to give it another shot, now that it's at 4.1.
This version has been rock solid, and so I was able to finally spend some time with it, setting it up "just-so" and such.
If you want to take your debugging to the next level by getting a nice stack / function trace on errors that occur, then you should check out Xdebug by Derick Rethans (who I had the pleasure to meet at php|works). I've only been touching the surface of this powerful extensions so far, but its already been a pleasure to work with and I'll try to write more about it in future. Maybe I can even integrate it into the CakePHP test suite for code coverage analysis at some point.








News von