Restler PHP API框架URL路由
我有一个关于框架的问题。我的CRUD基于你的活生生的例子。我有这个网址:Restler PHP API框架URL路由,php,api,rest,Php,Api,Rest,我有一个关于框架的问题。我的CRUD基于你的活生生的例子。我有这个网址: http://mydomain.com/test/index.php/api/t1/module1/username@mail.com?query1=mama&query2=papa 在我的api.php文件中,我对这个请求使用了GET方法: public function __construct(){ $this->dp = new Control(); } public function ge
http://mydomain.com/test/index.php/api/t1/module1/username@mail.com?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] => username@mail.com
[3] =>
)
我想在这里实现的是获得query1和query2的值?我该怎么做
谢谢。我创建了以下概念验证,并对其进行了测试,确保其正常工作
<?php
class Api {
public function get($id = NULL, $id2 = NULL, $id3 = NULL, $id4 = NULL, $query1 = NULL, $query2 = NULL) {
return "$query1 $query2";
}
}
或
或
我明白了
因此,我应该能够轻松地将它传递给另一个类另一种方法感谢您的回复。它不起作用。我现在要做的是从$\u服务器['QUERY\u STRING']获取值,但对我来说这不是最好的方法。它工作得很好!我已经用概念证明测试并更新了上面的示例。如果这不是你想要的,让我知道
<?php
require_once '../../restler/restler.php';
require_once 'api.php';
$r = new Restler();
$r->addAPIClass('Api');
$r->handle();
http://restler2.dev/test/url_routing/index.php/api/t1/module1/username@mail.com?query1=mama&query2=papa
http://restler2.dev/test/url_routing/index.php/api/t1/module1?query1=mama&query2=papa
http://restler2.dev/test/url_routing/index.php/api/t1?query1=mama&query2=papa
"mama papa"