An experimental REST API framework for PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Build Status

Create a file named "hello.php" with the following contents :

namespace veneer\endpoint\hello;
class v1 extends \veneer\call
    public $get = array('/:name' => 'hello');
    public function hello($args)
        return $this->response->set("Hello, {$args['name']}!", 200);

And a file called "run.php" with these contents:

require 'veneer/veneer.php';
require 'hello.php';

Run this command :

$ php run.php
veneer\http\server : Validating PHP environment...
veneer\http\server : Found endpoint: v1/hello
veneer\http\server : Listening on

Then try out your new API :

$ curl http://localhost:8080/v1/hello/world
"Hello, world!"


How can I get the output in another format?

$ curl http://localhost:8080/v1/hello/world?format=json
$ curl -H 'format: json' http://localhost:8080/v1/hello/world

The default serialization type is json, but you can configure that by calling \veneer\app::set_default('output_handler', 'xyz'), where xyz is any other output handler. You can also change the parameter that indicates the output handler by calling \veneer\app::set_default('output_handler_param', 'xyz'), where xyz is the parameter name. Other built-in handlers include serialize, plain, and html. You can easily add to the available output handlers. Take a look in veneer/output/handler/* for some examples.

How can I use this under Apache, Nginx, Lighttpd, or web server x?

Rewrite all requests to your run.php file (or whatever you called it)


RewriteEngine On
RewriteRule ^(.*)$ run.php [QSA]


rewrite ^ run.php?$args? ;


url.rewrite = (
  "^(.*)$" => "run.php$1"

run.php file

require 'veneer/veneer.php';
require 'hello.php';
// Note this call to run(), not listen()

What about some more advanced features?

This readme is kept to a minimum. You can read about some more advanced functionality by reading the wiki

Build it into an RPM

If you use a RedHat-based distribution, you can easily build a shared installation of veneer into an RPM by following these steps:

  1. Download a release and name the archive veneer.tar.gz:
curl -o veneer.tar.gz
  1. Build it with rpmbuild:
rpmbuild -tb veneer.tar.gz