国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

webman自動(dòng)映射路由能否讓url支持中劃線

aphper

想讓url中controller、action部分兼容兼容中劃線,中劃線更加符合SEO標(biāo)準(zhǔn)也更美觀
例如 /security/update-password 將訪問(wèn) securityController 控制器的 updatePassword 方法
每條都注冊(cè)路由麻煩

閱讀了一下代碼,在
框架核心App.php 類 getControllerAction方法添加如下代碼

$controller_class = str_replace(' ', '', ucwords(str_replace('-', ' ', $controller_class)));
$action = str_replace(' ', '', ucwords(str_replace('-', ' ', $action)));

實(shí)測(cè)可行 也不會(huì)對(duì)框架現(xiàn)有用戶產(chǎn)生影響,github發(fā)了PR,但是是第一次發(fā) 不知道是不是操作有問(wèn)題群主看不到,望群主能通過(guò)下這段改動(dòng)

中劃線更加符合SEO標(biāo)準(zhǔn)也更美觀

1454 1 0
1個(gè)回答

walkor 打賞

重新發(fā)pr吧,你的pr里帶了其它文件代碼,src/Auth/AuthManger.php 什么的不要提交。

$controller_class = str_replace(' ', '', ucwords(str_replace('-', ' ', $controller_class)));
$action = str_replace(' ', '', ucwords(str_replace('-', ' ', $action)));

這個(gè)寫得太繁瑣了,改成

$controller_class = str_replace('-', ' ', $controller_class);
$action = str_replace('-', ' ', $action);

看下是否ok

  • aphper 2022-05-09

    我從Yii2抄過(guò)來(lái)的代碼 好像是最簡(jiǎn)單的實(shí)現(xiàn)了 你寫的這段會(huì)報(bào)錯(cuò) method名有空格

  • aphper 2022-05-09

    重新PR了

  • walkor 2022-05-09

    發(fā)錯(cuò)了,替換成

    $controller_class = str_replace('-', '', $controller_class);
    $action = str_replace('-', '', $action);
  • aphper 2022-05-10

    這樣 不管是i-ndex還in-dex或者ind-ex都能訪問(wèn)到index去了

  • walkor 2022-05-10

    除了不自動(dòng)轉(zhuǎn)大寫字母,其它和你的沒(méi)區(qū)別吧

  • aphper 2022-05-10

    ....區(qū)別很大啊 不管你訪問(wèn) index/i-index、index/in-dex、index/ind-ex都會(huì)跑到index控制器的index方法去

  • walkor 2022-05-11

    你pr也是一樣的效果,index/i-index、index/in-dex、index/ind-ex都會(huì)跑到index控制器的index方法去。
    這樣好像確實(shí)不好

  • aphper 2022-05-11

    不會(huì)啊 我測(cè)試過(guò) 都是從Yii直接copy過(guò)來(lái)的 很可靠

  • nitron 2022-05-11
    php方法命名不能重復(fù)也不區(qū)分大小寫,所以walkor那個(gè)跟你的是一樣的效果
    所以不管你是function Log/LOg/LOG/lOg/loG ... 最后->log都能調(diào)用
    
    打個(gè)比方,你要Request-For-Something, 你要精確匹配,那么方法名只能是request_for_something, - 轉(zhuǎn) _
年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??