开发者

Class Or Framework To Help Build PHP RESTful API [closed]

It开发者_如何学Go9;s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

I am looking to create a RESTFul PHP based API, and I am wondering if there are any good prebuilt REST server classes or frameworks?

Basically just want a class to handle routing, and finally, it should be able to return back JSON or XML. I don't care about the VERB types (GET, POST, PUT, DELETE), because for example, if somebody wants to delete a record, I want them to be able to simply type in a URL into their browser to delete. If you look at the VERB, and only allow DELETE, its means this inst possible.

An example, is that I want to be able to write a simple class like:

class Customers {
    public function get($customer_id) {
        //{ "response" : [ { "first" : "Bob", "last" : "Smith", "company" : "ABC Inc." } ] }
    }

    public function delete($customer_id) {
       //{ "response" : "deleted" }
    }

    //POST
    public function create($first_name, $last_name, $company) {
       //{ "response" : "12322" }
    }
}

Which would create the following routes:

/customers/get/12322
/customers/delete/12322
/customers/create *post data*

Thanks greatly.


See Fat-Free Framework, specifically F3::map()


I've used http://code.google.com/p/php-rest-api/ as a base on a couple of large scale project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜