Minimalistic code for building RESTful APIs
PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
src
.gitignore
.travis.yml
LICENSE
README.md
phpunit.xml.dist

README.md

PHP REST Micro Framework

A simplistic micro framework for building an application providing a RESTful API.

Prerequsites

Usage

Have a look at /example/application.php for a quick start. It creates a Router and the Application, sets up a Route for / that will return a JSON response containing "Hello World!" to the client.

You can use PHP's builtin webserver to test it for yourself!

Start the server by running php -S localhost:8000 example/application.php:

$ php -S localhost:8000 example/application.php
PHP 5.6.2 Development Server started at Tue Sep 22 14:50:29 2015
Listening on http://localhost:8000
Document root is /Users/sebastian/projects/php/restframework
Press Ctrl-C to quit.

Send a request to http://localhost:8000/:

$ curl http://localhost:8000/
{
    "message": "Hello World!"
}

Sending requests to other routes or with other HTTP methods will result in a 404 response:

$ curl -X PUT http://localhost:8000/
{
    "error": {
        "code": 404,
        "message": "No route for put \/"
    }
}

$ curl http://localhost:8000/foo
{
    "error": {
        "code": 404,
        "message": "No route for get \/foo"
    }
}