PHP Tool - Krumo


For all this while, I have been using PHP print_r and var_dump functions to do simple PHP code debugging, until I found this tool called Krumo.

To put it simply, Krumo is a replacement for print_r() and var_dump(). By definition Krumo is a debugging tool (initially for PHP4/PHP5, now for PHP5 only), which displays structured information about any PHP variable.

A lot of developers use print_r() and var_dump() in the means of debugging tools. Although they were intended to present human readble information about a variable, we can all agree that in general they are not. Krumo is an alternative: it does the same job, but it presents the information beautified using CSS and DHTML.

Except the collapsible DHTML tree built around the structure of the dumped PHP variable, and the improved by the CSS looks, Krumo offers additional useful features.

For example haven’t been disappointed that you can not see the name of the variable passed for dumping ? Calling it many times, you will not be able to know which dump value was provided by a certain variable at a certain time in a certain place of your code. Well, Krumo can not do that either, but it offers a work- around: it prints the code line that the Krumo call was placed: in this way you can keep track of the origin of each dump you see on the screen.

Another nice addition to the set of Krumo features is the ability to turn it off. When your code gets swamped with a lot of dumping calls, instead of cleaning them up, you can just turn them off. You go to admit that this beats the alternative of going through your code and removing every dumping route you have … right ?

A lot of times you need to dump the contents of the superglobals ($_GET, $_POST, $_SERVER, $_SESSION, etc), or see the list of included files, or the declared classes and interfaces, or the defined constants, etc. Krumo offers an easy, fast and graceful way to do this with just one simple call: see the examples area for demonstration, or just load this page to see the results.

Why I use Fedora Linux?


Just go through a list of projects the Fedora community has in mind, I am sure, you will be using one of this technology in a very near future. Fedora provides developers a place to host their code and collaborate online. It provide each project with source control via git, Mercurial, bzr, Subversion, and others, as well as a bug tracker and wiki via Trac.

One of the project which I am looking forward is Func (Fedora Unified Network Controller). Below are some information about what Func does, which I extracted it from their official wiki:

So, if I want Words, What Is Func?

Func allows for running commands on remote systems in a secure way, like SSH, but offers several improvements.

  • Func allows you to manage an arbitrary group of machines all at once.
  • Func automatically distributes certificates to all “slave” machines. There’s almost nothing to configure.
  • Func comes with a command line for sending remote commands and gathering data.
  • There are lots of modules already provided for common tasks.
  • Anyone can write their own modules using the simple Python module API.
  • Everything that can be done with the command line can be done with the Python client API. The hack potential is unlimited.
  • You’ll never have to use “expect” or other ugly hacks to automate your workflow.
  • It’s really simple under the covers. Func works over XMLRPC and SSL.
  • Since func uses certmaster, any program can use func certificates, latch on to them, and take advantage of secure master-to-slave communication.
  • There are no databases or crazy stuff to install and configure. Again, certificate distribution is automatic too.

PHP by example - Simple XML Parsing with SimpleXML


I have read and answered some PHP questions related to XML at DevNetwork Forums, many PHP programmer does not know how to parse XML into string from external resources. Let take an example, I would like to have a Kuala Lumpur weather forecast for my blog, I can retrieve the information from Yahoo! Weather RSS feed in XML formatted document, how do I parse the XML into string using PHP? You just have to use php_get_contents function with SimpleXML extension :

<?php
 
// get kuala lumpur wheather forecast 
$content = file_get_contents('http://xml.weather.yahoo.com/forecastrss?p=MYXX0008');
 
// parse the xml document to array
$xml = new SimpleXMLElement($content);
 
// print the xml element into string
print_r($xml);
 
?>

There is a better way to process the RSS feeds, Read my previous post about Zend_Feed.