ilijamt
(Ilijamt)
November 28, 2012, 12:50pm
1
I have the following problem, according to the documentation the following
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
array('api/<model>/list', "pattern" => "api/<model:\w+>", 'verb' => 'GET')
)
);
When I call GET host/api/messages it should evaluate as host/api/messages/list, but for some reason it is not working it is trying to open the index function and not the list function.
Should I call GET host/api/messages/list everything works as expected.
Can anyone help me with this problem?
Also I was wondering if I have the following in the rules array
array('api/<model>/update', 'pattern' => 'api/<model:\w+>/<id:\d+>', 'verb' => 'PUT')
Can I evaluate it to be PUT host/api/messages/1 instead of PUT host/api/messages/id/1
Janoo
(Pocak87)
November 28, 2012, 1:14pm
2
Hy,
I use this syntax:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
'rules'=>array(
'' => 'sites',
'rss' => 'sites/feed',
'news/page-<page:\d+>'=>'post/index',
'news/' => 'post/index',
'news/<id:\d+>/<title:([a-z -_]*)>'=>'post/view',
)
),
this is a huge pattern: ‘news/page-<page:\d+>’
and it is routed to ‘post/index’,
what written in "< … >" -> that going be in $_GET superglobal
example: ‘news/<id:\d+>/<title:([a-z -_]*)>’ => $_GET[‘id’] and $_GET[‘title’]
you can check it
function public actionIndex(){
$aa = $_GET['id']. ' - ' .$_GET['title'];
print($aa);
exit;
}
ilijamt
(Ilijamt)
November 28, 2012, 1:20pm
3
Janoo:
Hy,
I use this syntax:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
'rules'=>array(
'' => 'sites',
'rss' => 'sites/feed',
'news/page-<page:\d+>'=>'post/index',
'news/' => 'post/index',
'news/<id:\d+>/<title:([a-z -_]*)>'=>'post/view',
)
),
this is a huge pattern: ‘news/page-<page:\d+>’
and it is routed to ‘post/index’,
what written in "< … >" -> that going be in $_GET superglobal
example: ‘news/<id:\d+>/<title:([a-z -_]*)>’ => $_GET[‘id’] and $_GET[‘title’]
you can check it
function public actionIndex(){
$aa = $_GET['id']. ' - ' .$_GET['title'];
print($aa);
exit;
}
You are right turns out there were two urlManager sections and that is why it wasn’t working.
As soon as I removed the second one it started working.