Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何组织Luracast Restler类来创建相关的管线端点?_Php_Api_Frameworks - Fatal编程技术网

Php 如何组织Luracast Restler类来创建相关的管线端点?

Php 如何组织Luracast Restler类来创建相关的管线端点?,php,api,frameworks,Php,Api,Frameworks,我正在使用Luracast Restler API框架,我想知道如何组织类结构来创建这种风格的路由 webroot/user/:id/ webroot/user/:id/profile webroot/user/:id/tweets 可以对以下各项使用GET、PUT、POST、DELETE: Class user(){ function get($id){ Do something when GET/webroot/user/:id/ } function put($data

我正在使用Luracast Restler API框架,我想知道如何组织类结构来创建这种风格的路由

webroot/user/:id/
webroot/user/:id/profile 
webroot/user/:id/tweets 
可以对以下各项使用GET、PUT、POST、DELETE:

Class user(){
 function get($id){
   Do something when GET/webroot/user/:id/ 
 }
 function put($data){
   Do something when PUT/webroot/user/:data/ 
 }
}
Class profile(){
 function get($id){
   Do something when GET/webroot/user/:id/profile 
 }
}
Class tweets(){
 function get($id){
  Do something when GET/webroot/user/:id/tweets
 }
}

提前谢谢

您需要使用PHP文档注释使用自定义url路由。下面是您的用例的修改示例

Class User(){
 function get($id){
   //Do something when GET /webroot/user/:id/ 
 }
 function put($data){
   //Do something when PUT /webroot/user/:data/ 
 }
 /**
 * @url GET /:id/profile
 */
 function profile($id){
   //get the profile for specified user
 }
}

您可以使用POST、DELETE、PUT替换该方法进行配置文件编辑。还请注意,您可以使用上述语法添加多个路由。

其他CRUD方法是否允许自定义路由

/**
* @url POST /create
*/      
protected function post($request_data=NULL) {
    return $this->dp->insert($this->_validate($request_data));
}
我给邮局打过电话

Prepared POST URLRequest '<NSMutableURLRequest http://myserver.com/base/_006_crud/user>'. HTTP Headers: {
    Accept = "application/json";
    "Content-Type" = "application/x-www-form-urlencoded";
}. HTTP Body: ssoid=123&ssotype=facebook&crudID=0&ssoname=mickey.

到目前为止你试过什么?你遇到了什么具体问题?官方规范是什么?您的类是否使用它?
response body: {
  "error": {
    "code": 404,
    "message": "Not Found"
  }
}