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

webman自動映射路由能否讓url支持中劃線

aphper

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

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

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

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

中劃線更加符合SEO標準也更美觀

1511 1 0
1個回答

walkor 打賞

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

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

這個寫得太繁瑣了,改成

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

看下是否ok

  • aphper 2022-05-09

    我從Yii2抄過來的代碼 好像是最簡單的實現(xiàn)了 你寫的這段會報錯 method名有空格

  • aphper 2022-05-09

    重新PR了

  • walkor 2022-05-09

    發(fā)錯了,替換成

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

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

  • walkor 2022-05-10

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

  • aphper 2022-05-10

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

  • walkor 2022-05-11

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

  • aphper 2022-05-11

    不會啊 我測試過 都是從Yii直接copy過來的 很可靠

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