robotpony / Presto

Simple tools for building RESTfull interfaces. This is an old and unmaintained project.
http://presto.napkinware.ca
Other
11 stars 3 forks source link

Namespace + Presto #75

Closed robotpony closed 11 years ago

robotpony commented 11 years ago

This patch moves Presto into a namespace, breaking compatibility with the 1.1 and earlier branches.

Changes include:

Note that while this has been tested with some of my test projects, it is new and going to be fragile. Extra trace logging has been added to help with reporting bugs.

Updated API requirements

An API now will look something like:

<?php

namespace napkinware\foo;
use napkinware\presto as presto;

require_once('models/foo.php');

class bar 
    extends presto\API {

    public function __construct() {
        parent::__construct('foo');
        presto\trace('Startup ok');
    }

    public function get($path, $options, $b, $t) {
        throw new \Exception('Not found', 404);
    }

    public function get_thing($path, $options, $body, $type) {
        $dom = new foo($path, $options, $body, $type);

        return $dom;
    }
}

The example aliases the namespace for simpler usage, and shows the API itself being in a different namespace than the presto library.

FYI @adam-patterson and @ngallagher87 - we'll migrate to this in future projects, once it's fully baked.