Cakephp 3 - 创建完整的URL

时间:2016-02-09 08:57:10

标签: url cakephp cakephp-3.0

我喜欢做的是创建一个完整的网址。

Controller = 'A'
Action = 'doSomething'
param1 = $id
param2 = $id2

我目前得到的是: mydomain.com/A/doSomething?param1=X&param2=XX

我想要的是: mydomain.com/A/doSomething/X/XX

代码:

$message = 'Test: '. Router::url([
    "controller" => "A",
    "action" => "doSomthing",
    "param1" => $id,
    "param2" => $id2,
    '_full' => true
]);

2 个答案:

答案 0 :(得分:2)

$id1 = 'id1';
$id2 = 'id2';

$url= Router::url([
    "controller" => "A",
    "action" => "doSomething",
    $id1,
    $id2,
    '_full' => true
]);

debug($url);

输出:

  

' http://host/a/do-something/id1/id2'

答案 1 :(得分:0)

尝试:

public function doSomthing($param1, $param2)
{
#your code here
}