Verycong与齐博
关于 自定义路径中的 route.php 与 routemy.php 的应用
1472
3

官方升级后没有说明,那么,此建议由我提出,就由我来说明一下。

由于官方开发新模块后总是会升级  route.php ,如果我们使用  route.lock 功能,那新模块的规则又需要我们手动去添加。


那是经过建议,官方升级了。

if (is_file(APP_PATH.'routemy.php')) {      //用户自定义的路由规则
    include APP_PATH.'routemy.php';
}

也就是优先调用   routemy.php 的文件,

这个文件中的 规则会优先 route.php中的规则哦。

<?php
use think\Route;
Route::group(['name'=>'yuanliao','ext'=>'html'], [
        'show-<id>$'	=>['yuanliao/content/show',['method'=>'get'],['id' => '\d+']],
        'list-<fid>'=>['yuanliao/content/index',['method'=>'get'],['fid' => '\d+']],
        'mid-<mid>$'=>['yuanliao/content/index',['method'=>'get'],['mid' => '\d+']],
        'show'	=> 'yuanliao/content/show',
        'list'	=> 'yuanliao/content/index',
        'index'	=> 'yuanliao/index/index',
]);
/*测试优先*/
Route::group(['name'=>'info','ext'=>'html'], [
        'show-<id>$'	=>['cms/content/show',['method'=>'get'],['id' => '\d+']],
        'list-<fid>'=>['cms/content/index',['method'=>'get'],['fid' => '\d+']],
        'mid-<mid>$'=>['cms/content/index',['method'=>'get'],['mid' => '\d+']],
        'show'	=> 'cms/content/show',
        'list'	=> 'cms/content/index',
        'index'	=> 'cms/index/index',
]);

Route::group(['name'=>'goodurl','ext'=>'html'], [
        'show-<id>$'	=>['goodurl/content/show',['method'=>'get'],['id' => '\d+']],
        'list-<fid>'=>['goodurl/content/index',['method'=>'get'],['fid' => '\d+']],
        'mid-<mid>$'=>['goodurl/content/index',['method'=>'get'],['mid' => '\d+']],
        'show'	=> 'goodurl/content/show',
        'list'	=> 'goodurl/content/index',
        'index'	=> 'goodurl/index/index',
]);


默认应该是没有 routemy.php文件的,

所以请大家可以自己新建一个(别用记事本哦),复制的模块,什么的,都可以放在这个规则文件中。

以后官方升级了route.php并不会更改你的规则了。

10
赏礼
赏钱
收藏
点击回复
      全部留言
  • 3
更多回复
恢复多功能编辑器
  • 3 1
  • Verycong与齐博
        圈内贴子488
    • 圈子成员22
    本圈子内的新贴

    推荐内容
    扫一扫访问手机版
    请选择要切换的马甲:

     
    网页即时交流
    QQ咨询
    咨询热线
    020-28998648