Slawek Lukasiewicz’s Blog: Zend Framework: Reflection

Slawek Lukasiewicz has a recent post to his blog looking at a tool that comes bundled with PHP that can help you find out more about your own code (or really any other piece of code out there) – the Reflection API. In his post he looks specifically at the functionality the Zend Framework has built on top of the base PHP API.

Zend Framework has own Reflection extension. It is mostly build upon genuine PHP Reflection API and extends existing features. The completely new Zend_Reflection module feature is introspection of docBlock tags.

He includes two code examples using this component of the framework – grabbing the docblock off of a specific method (and even how to grab specific tags from inside it) and how to grab the body content out of a given method, with or without the docblock attached.

Jason Gilmore’s Blog: Thirteen Zend Framework Tutorials

Jason Gilmore has posted a new article with a list of thirteen tutorials all centered around the Zend Framework but on a wide variety of topics.

A few weeks ago I posted what turned out to be a rather popular compendium of productivity- and best practices-related PHP tutorials which I’ve published in recent years on Developer.com and PHPBuilder.com. As it happens I write about the Zend Framework with equal vigor, and figured readers might like to check out the list of Zend Framework tutorials I’ve written over the past two years for the aforementioned sites. With no further ado, here’s the list.

Among the tutorials on the list are things like:

Zend Developer Zone: Caching of Zend Framework application confi…

On the Zend Developer Zone today there’s a new post showing how you can cache your application configuration file to boost the performance of your Zend Framework application just a little bit more.

read more

Zend Developer Zone: Caching of Zend Framework application configuration file

On the Zend Developer Zone today there’s a new post showing how you can cache your application configuration file to boost the performance of your Zend Framework application just a little bit more.

If you think that you’ve done everything in terms of performance optimization of your Zend Framework-based project, I bet that your application configuration file was not included in that process. [...] Reason why I’m referring to application config is that its parsing is performed on every request, which is certainly unnecessary, as you don’t make configuration changes very often. Solution is simple – cache it.

He opts for an APC-based solution that, in the bootstrap, reads in the configuration file and caches it as a part of a custom Zend_Application object. Code is included for both the addition to the bootstrap and the custom class extending Zend_Application to handle the actual caching.

Zend Developer Zone: Announcing the May 2011 Zend Framework Bug-…

This new post on the Zend Developer Zone (from Ralph Schindler) is announcing this month’s Zend Framework Bug Hunt Days starting today (the 26th) and running through Saturday (the 28th).

read more

Zend Developer Zone: Announcing the May 2011 Zend Framework Bug-Hunt

This new post on the Zend Developer Zone (from Ralph Schindler) is announcing this month’s Zend Framework Bug Hunt Days starting today (the 26th) and running through Saturday (the 28th).

For those who haven’t put the reoccurring event in their calendar, this announcement is for you: Zend Framework Monthly Bug-hunt is here again! Tomorrow, Friday and Saturday of May (the 26th, 27th and 28th 2011), we’ll be hosting our monthly bug hunt. For those of you unfamiliar with the event, each month, we organize the community to help reduce the number of open issues reported against the framework.

He mentions last month’s winner, Adam Lundrigan, and some hints on how to get started (including a few screenshots on helping you find issues to work on). See the rest of the post for complete information.

Slawek Lukasiewicz’s Blog: Zend Framework: logging with Firebug and FirePHP

Slawek Lukasiewicz has a new post to his blog today showing you how to use the popular Firebug extension for Firefox with the FirePHP plugin to make error logging simpler and less obtrusive without ever having to leave the browser.

If you use Firefox, I bet you already know Firebug extension. This is irreplaceable tool for web development. But there is also FirePHP extension, which provides possibility to log into Firebug console from PHP scripts. This is very convenient way for debugging process, because logs are independent from application output.

He shows the integration you can do with the Zend Framework’s Zend_Log component to write basic messages and the Zend_Wildfire component to write tabular data back to your browser’s console with two snippets of code.

Web Species Blog: The New Era of PHP Frameworks

On the Web Species blog there’s a new post from Juozas Kaziukenas about the new era of PHP frameworks that are coming out (or might be already here). This new group of frameworks is redefining the PHP framework world:

I have worked on a lot of different systems and projects in my years and most of that was spent doing PHP. However just recently I have noticed a new major point in time – a new era of PHP frameworks. Seems like everything is changing these days. I want to discuss what I think the current state is, what’s wrong with it and how the new gang of frameworks is going to change it.

Juozas starts with a brief history of the “why” and “how” PHP frameworks came to be and how they’ve improved over time. In this new generation things like dependency injection containers and annotations are changes for the better. Three frameworks mentioned specifically as driving forces in this new movement are Zend Framework 2.0, Lithium and Symfony2.

Yahoo’s weather API and the yweather: namespace

While developing mooooody.com at Yahoo’s hackathon, I stumbled on a small problem: parsing Yahoo Weather’s results in PHP with simple_xml. The problem arose from Yahoo’s use of the yweather: namespace. By default, SimpleXML cannot parse tags like yweather:astronomy.

Being somewhat intellectually impaired by prolonged sleep depravation – I thought to just search the web for a solution and not come up with one myself. It was a hackathon, the point was to hack the app together fast, not write state of the art code. So, after a bit of googling around, I landed on this spanish blog. The guy’s idea was to just do a str_replace to remove all the yweather: bits and then parse it as regular XML. After a short talk with the team, we decided that we’re not *that* tired and we looked for a better solution.

Which came shortly after in the form of registering the proper namespace with the SimpleXML object. Check it out:

$response = file_get_contents('http://weather.yahooapis.com/forecastrss?w=868274&u=c');
$xml = new SimpleXMLElement($response);
 
$xml->registerXPathNamespace(
    'yweather',
    'http://xml.weather.yahoo.com/ns/rss/1.0'
);
 
$astronomy  = $xml->xpath('//yweather:astronomy');
$attributes = $astronomy[0]->attributes();
$sunrise    = (string) $attributes['sunrise'];
$sunset     = (string) $attributes['sunset'];
 
printf('In Bucharest, the sun rises at %s and sets at %s',
       $sunrise, $sunset);

Needless to say, it worked. Enjoy Mooooody.



Josh Adell’s Blog: Logging User Sessions Across Requests

Josh Adell has a new post to the Everyman Software blog talking about a solution he and his team have developed for logging user sessions across requests with the help of the Zend_Log component and a custom logging formatter.

One way to handle this is to put a request-specific identifier in every log message. But I shouldn’t have to remember to append or prepend the identifier to their log messages. I’d rather have it happen automatically, without me or my teammates having to think about it. Here’s a method we’ve been using to try and untangle the mess and retain the usefulness of our logs. The code uses Zend’s logging component, but can easily be adapted to other log systems.

Their example sets a custom log format message with placeholders for a timestamp, log ID number and the log message. A unique ID is then generated for the user’s session and applied to the Zend_Log object. This data is then automatically applied to the log file’s output without any extra hassle. The full sample code (pretty simple, really) is included.