用于帮助构建PHP RESTful API的类或框架[关闭]

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.

查看全部
donglu2523
donglu2523
2010/11/15 06:31
  • rest
  • php
  • api
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复