それはルーティングと関係がありますね。私は自分のコードからこれを変更しました。グループ化を使用しました。その必要はありません。このコードはテストしていません。
// routes.php
$router = new \Phalcon\Mvc\Router();
$router->setDefaultModule("__YOUR_MODULE__");
$router->removeExtraSlashes(true);
... your other routes ...
// posts group
$posts = new \Phalcon\Mvc\Router\Group(array(
'module' => '__YOUR_MODULE__',
'controller' => 'posts',
'action' => 'index'
));
// All the routes start with /post
$posts->setPrefix('/post');
$posts->add('/{postName}/:params', array(
'action' => 'index',
'params' => 2
));
// Maybe this will be enough for your needs,
// the one above has a catch all params, which
// has to be manually parsed
$posts->add('/{postName}', array(
'action' => 'index',
));
$posts->add('[/]*', array(
'action' => 'index',
));
$router->mount($posts);
unset($posts);
... other routes ...
return $router;
postName
コントローラーでは、次の方法でパラメーターを取得できます。
$this->dispatcher->getParam('permaPath');
phalcon ルーティングのドキュメントに示されているように、ルーティング構成で正規表現を使用できます。
$posts->add('/{postName:[-0-6_A-Za-z]+}/:params', array(
'action' => 'index',
'params' => 2
));
したがって、、、、のみが-_
許可されます。URL にカンマが含まれている場合は、ルートが一致せず、404 ページが見つかりません。0-9
A-Z
a-z
postName