thekoushik / sresto

A very simple lightweight PHP REST Framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SRESTO

A very simple lightweight PHP REST Framework

Install

composer.json

{
    "repositories": [
        {
            "type":"vcs",
            "url":"https://github.com/thekoushik/sresto.git"
        }
    ],
    "require": {
        "thekoushik/sresto": "dev-master"
    },
    "minimum-stability": "dev"
}

Then run in your terminal

$ composer install

Basic Usage

require __DIR__ . '/vendor/autoload.php';

use SRESTO\Router;

$router=new Router();

$router->get("/hello",function($req,$res,$s){
    $res->message("Hello World");
});
$router->execute();

Test it

$ curl -GET "http://localhost/helloworld/?/hello"

will print

{"message":"Hello World"}

URL parameters

$router->get("/:id",function($req,$res,$s){
    $res->message("Your id is ".$req->param['id']);
},['id'=>'digits']);

where

$ curl -GET "http://localhost/helloworld/?/2323"

will print

{"message":"Your id is 2323"}

Supported Param Types

  • digits
  • alphabets
  • alphanumerics

About

A very simple lightweight PHP REST Framework

License:MIT License


Languages

Language:PHP 96.9%Language:Makefile 3.1%