Restler PHP API 框架 URL 路由
我有一个关于框架的问题。我的 CRUD 基于您的实例。我有这个 URL:
http://mydomain.com/test/index.php/api/t1/module1/[email protected]?query1=mama&query2=papa
在我的 api.php 文件中,我对此请求使用了 GET 方法:
public function __construct(){
$this->dp = new Control();
}
public function get($id=NULL, $id2=NULL, $id3=NULL, $id4=NULL)
{
switch($id)
{
case "t1":
return $this->dp->t1(func_get_args());
break;
case "t2":
return $this->dp->t2(func_get_args());
break;
default:
throw new RestException(400);
break;
}
}
然后在我的 control.php 上,
public function t1($numbers) {
print_r($numbers);
}
其响应正文是
数组 ( [0] => t1 [1] =>模块1 [2] => [电子邮件受保护] [3] => )
我想在这里实现的是获取query1和query2的值?我该怎么做?
谢谢。
I have a question regarding the framework. I based my CRUD on your live example. I have this URL:
http://mydomain.com/test/index.php/api/t1/module1/[email protected]?query1=mama&query2=papa
In my api.php file, I used GET method on this request:
public function __construct(){
$this->dp = new Control();
}
public function get($id=NULL, $id2=NULL, $id3=NULL, $id4=NULL)
{
switch($id)
{
case "t1":
return $this->dp->t1(func_get_args());
break;
case "t2":
return $this->dp->t2(func_get_args());
break;
default:
throw new RestException(400);
break;
}
}
Then on my control.php,
public function t1($numbers) {
print_r($numbers);
}
The response body of this is
Array
(
[0] => t1
[1] => module1
[2] => [email protected]
[3] =>
)
What I want to achieve in here is get the values of query1 and query2? How can I do this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我创建了以下概念验证并对其进行了测试并确保其有效!
为了托管上面的API,我使用以下index.php(网关)
当我调用
或
或
我得到
所以我应该能够轻松地将它传递给另一个类另一个方法
I have created the following proof of concept and tested it and made sure it works!
For hosting the API above I use the following index.php (gateway)
When I call
or
or
I get
So I should be able to pass it to another class another method easily