ARC: Ariadne Components

A flexible component library for PHP 5.3+

View project onGitHub

ARC: Ariadne Components.

The Ariadne Component Library is a spinoff from the Ariadne Web Application Framework and Content Management System [ http://www.ariadne-cms.org/ ]

Note: ARC is very much a work in progress. It is by no means complete yet. Check the tests directory to see which parts are tested. The XML component still doesn't pass all tests, so beware :)

It is designed to make it simpler to do many common web application tasks in a way that is easy to extend and is standards compliant and accessible by default. The components are loosely coupled, they can generally be used seperately but can be combined to enable more features.

It doesn't provide a MVC (Model View Controller) framework or URL router, that is left to other frameworks.

Examples

Event handling, with capture and listen phase, seperate preventDefault and event cancelling, path aware events and handlers:

$listener = \arc\events::cd('/sub/path/')->listen( 'myEvent' )
    ->call( function( $event ) {
         // do something
    } );

Firing events:

$result = \arc\events::cd('/sub/path/child/')
    ->fire( 'myEvent', array( 'extra' => 'data' ) );
if ( $result ) {
     // do default action
}

Caching:

$result = \arc\cache::cache('cacheName', function() {
    // do something that takes time
    return $value;
});

Generic caching proxy:

$cachingHttpClient = \arc\cache::proxy( \arc\http::client(), '1 hour' );

XML parsing and generation:

$rss = \arc\xml::parse( $someRSS );
$titles = $rss->rss->item->title->nodeValue;

or simpler:

$titles = $rss->find('item title')->nodeValue;

generation:

$rss->rss->items[] = \arc\xml::el('item');
echo $rss; // full rss xml output, including xml preamble

There's a lot more, take a look at the wiki pages for the full API.

A key difference between ARC and most other libraries or components doing similar stuff is that many of the ARC components understand filesystem like hierarchies. The events component for example allows you to fire or listen to an event at a certain path. That is what the cd() method is doing there. Any event fired on such a path first checks listeners in the capture phase from the root ( '/' ) up to the path the event was actually fired on. Then it bubbles back up to the root in the listen phase. In effect we use a path based hierarchy like your browser uses the DOM hierarchy.

You don't have to use these paths, but most of the components support it. Ariadne is a CMS built based on a structured object store with a filesystem like content hierarchy. All these components are designed to work well with that concept.