【发布时间】:2011-11-09 00:49:53
【问题描述】:
我一直在使用“Migrating from CakePHP 1.2 to 1.3”指南将 CakePHP 从 1.2.10 升级到 1.3.11,我知道我必须确保我的路由与 1.3 兼容。
但是我的路线没有做任何不兼容的事情:
这不再受支持,因为中途贪婪星的行为 不规则且复杂的路由编译。这两个之外 边缘情况功能和上述更改路由器的行为与 它在 1.2 中实现
另一种极端情况是:
删除了使用完整正则表达式的第一个路径段。
我的路线表现如何:
- 打开主页时,不起作用,但是在 1.2 上它成功匹配了路由 #1(由 Ivo 解决)
- /lv/products *不起作用*。应该使用控制器“Products”和默认操作“index”匹配 #6,但它认为“lv”是控制器(忽略 :lang 参数)
- /lv/products/index 有效!
- /lv/products/view/productname 有效!
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}")
);
感谢您的帮助。
【问题讨论】:
标签: php cakephp routes cakephp-1.3