Tonic is an open source less is more, RESTful Web application development PHP library designed to do things "the right way", where resources are king and the library gets out of the way and leaves the developer to get on with it.

To understand Tonic, you need to get the Web, so forget everything you know for a minute and think about how the Web really works, it's not about HTML pages, it's about resources:

Tonic helps you develop Web applications that embrace the way the Web really works, enabling your applications to scale, extend and work with other systems easily.

Quick Example

Front controller

Tonic uses the common front controller pattern to push all required traffic to a single script that then dispatches the request to the correct piece of developer logic to handle the request. The typical dispatcher PHP file looks like:

docroot/dispatch.php

Defining resources

With the dispatcher set up and all requests being forwarded to it by the Web server, we can then define a resource class to handle a request to a specific URL:

resource/example.php

Features

Content negotiation
Content and language negotiation support allowing you to easily pick the best representation for the client request.
Output encoding
Built-in support for compressed responses.
Client side caching
Support for sending correct cache control headers, entity tags, and 304 response codes.
Collection resources
Support for managing a collection of resources.

What Next?

The best place to start is to have a read through the README, then dig into the code and the examples.

Please checkout the code and have a play, comments and pull requests most welcome.

Created Jan 1, 2010, last modified Apr 24, 2011