GithubHelp home page GithubHelp logo

simful's Introduction

SimFul

SimFul is a PHP micro RESTFul library.

Usage

<?php

require_once 'SimFul.php';

$app = new SimFul();

$app -> cookie('SimFul_Key', 'SimFul_Value');
$app -> header('X-SimFul-Test', 'SimFul_TEST_Value');
$app -> header('Access-Control-Allow-Origin', '*');

$app -> init(function ($req, $resp) {
    echo 'init1 - ';
});

$app -> init(function ($req, $resp) {
    echo 'init2 - ';
});

$app -> get('/users', function ($req, $resp) {

    echo 'getUsers()';

    // init1 - init2 - getUsers()
});

$app -> get('/user/:id', function ($req, $resp) {

    echo 'getUser() - ' . $req['params']['id'];

    // init1 - init2 - getUser() - 5
});

$app -> get('/user/:id/item/:no', function ($req, $resp) {

    echo 'getUserItemSlot() - ' . $req['params']['id'] . ' - ' . $req['params']['no'];

    // init1 - init2 - getUserItemSlot() - 5 - 10
});

$app -> post('/user', function ($req, $resp) {

    echo 'addUser() - ' . json_encode($req['body']);

    // init1 - init2 - addUser() - { "name" : "u4bi", "age" : 17, "admin" : true }
});

$app -> put('/user/:id', function ($req, $resp) {

    echo 'updateUser() - ' . $req['params']['id'];

    // init1 - init2 - updateUser() - 5
});

$app -> patch('/user/:id', function ($req, $resp) {

    echo 'assignUser() - ' . $req['params']['id'];

    // init1 - init2 - assignUser() - 5
});

$app -> delete('/user/:id', function ($req, $resp) {

    echo 'removeUser() - ' . $req['params']['id'];

    // init1 - init2 - removeUser() - 5
});


$app -> run();

?>

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.