This patch moves Presto into a namespace, breaking compatibility with the 1.1 and earlier branches.
Changes include:
Adds napkinware\presto namespace
Autoloaders adjusted for namespace awareness
Helpers are no longer static class members (the namespace is enough)
Other minor improvements (like a better trace, allowing console.log style usage)
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.
This patch moves Presto into a namespace, breaking compatibility with the 1.1 and earlier branches.
Changes include:
napkinware\presto
namespaceconsole.log
style usage)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:
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.