Skip to content

paul-schulleri/minimal-rest

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
    }
}

About

Minimalistic code for building RESTful APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%