Fever Framework Update

I just want to update everyone on the status of the framework. It is still on schedule for the February 26th release!

As we countdown to the public beta release, I want to keep you informed of some exciting functionality that’s being added.

Functionality

Along with the JSON controller, a new XML controller has been added. This allows you to return nearly anything from an action and it will automatically convert it to XML, send the proper content-type header and provide the data to the client. Here is an example of how it would work:

<?php
 
class MyController extends \Fever\Controller\Action\AbstractXml
{
    public function getTestData()
    {
        return array
            (
            'name' => 'Will Fitch',
            'attributes' =>
                array(
                'height' => 76,
                'hair' => 'brown',
                'eyes' => 'brown'
                )
            );
    }
}

This will, in turn, produce the following XML document to the client:

<results>
    <name>Will Fitch</name>
    <attributes>
        <height>76</height>
        <hair>brown</hair>
        <eyes>brown</eyes>
    </attributes>
</results>

Now I’m sure there are those out there that are screaming, “But I want to customize the name of the elements!!!”. No problem! There is a method withing the AbstractXml controller called “setXmlElement” which accepts an instance of SimpleXMLElement. This will be used when converting data provided into XML.

This is all thanks to a new component called “XmlConverter” which lives in the \Fever\IO\Xml namespace. It follows the chain-of-command pattern and iterates until it finds the correct data type provided. Here are a list of converters available for iteration:

  • ArrayToXml
  • BooleanToXml
  • NullToXml
  • NumberToXml
  • ObjectToXml
  • StringToXml

All of these are separate entities, so they can be used independently.

I’ll continue to update throughout the upcoming days before the public beta!

Mega World News Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google Yahoo Buzz StumbleUpon Weekend Joy


Leave a Reply