V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
yakczh
V2EX  ›  PHP

slim 里面 get/post 请求分开处理有什么好处?

  •  
  •   yakczh · 2015-07-01 14:14:37 +08:00 · 2399 次点击
    这是一个创建于 3215 天前的主题,其中的信息可能已经有所发展或是发生改变。

    比如

    $app->get('/hello/:name', function ($name) {
    echo "Hello, $name";
    });

    $app->post('/hello/:name', function ($name) {
    echo "Hello, $name";
    });

    相比传统的 class xxController {

    function xxxAction($name){
        echo "hello".$name
      }
    

    }
    有什么好处吗?

    ywisax
        1
    ywisax  
       2015-07-01 16:15:27 +08:00
    可以提高灵活度。
    如果不想这样折腾,那就用map(.........)->via('GET', 'POST')来做吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2909 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 02:50 · PVG 10:50 · LAX 19:50 · JFK 22:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.