我使用“Migrating from CakePHP 1.2 to 1.3”指南将CakePHP从1.2.10升级到1.3.11,我知道我必须确保我的路由与1.3兼容。
但是我的路线不做任何不相容的事情:
不再支持这种方式,因为中途贪婪的星星表现得很好 不规则,复杂的路线编制。在这两个之外 边缘情况特征和上面的改变路由器的行为完全一样 它确实在1.2
另一个边缘案例是:
删除了使用完整正则表达式的第一个路径段。
Cake提供类似于此错误的错误(打开 / lv / products 时复制:
Missing Controller
Error: LvController could not be found.
Error: Create the class LvController below in file: app\controllers\lv_controller.php
<?php
class LvController extends AppController {
var $name = 'Lv';
}
?>
//Route #1: This route should have worked as a root route, because we have a default for :lang. But now i cannot open up the homepage if i don't define explicit "/" route
Router::connect("/:lang/",
array("controller" => "start", "lang" => "lv"),
array("lang" => "[a-z]{2}")
);
//#2 This route seems to work ok.
Router::connect("/admin/:lang/:controller/:action/*",
array("lang" => "lv", "admin" => true),
array("lang" => "[a-z]{2}")
);
// ==============================================================================
//#3 Routes with static parts - works
Router::connect("/:lang/info/*",
array("controller" => "sections", "action" => "view", "lang" => "lv"),
array("lang" => "[a-z]{2}")
);
//#4
Router::connect("/:lang/news",
array("controller" => "news", "action" => "listall", "lang" => "lv"),
array("lang" => "[a-z]{2}")
);
//#5
Router::connect("/:lang/employees",
array("controller" => "employees", "action" => "index", "lang" => "lv"),
array("lang" => "[a-z]{2}")
);
// ==============================================================================
//#6 Catch all route.
Router::connect("/:lang/:controller/:action/*",
array("lang" => "lv"),
array("lang" => "[a-z]{2}")
);
感谢您的帮助。
答案 0 :(得分:1)
对于默认的root,我猜你想要'/'
或'/<param>'
'/:lang/'
期待lang有什么东西 - 它不是可选的,afaik。请改为'/:lang'
。