Slim PHP and GET Parameters

后端 未结 9 516
猫巷女王i
猫巷女王i 2021-01-30 03:56

I\'m playing with Slim PHP as a framework for a RESTful API, and so far it\'s great. Super easy to work with, but I do have one question I can\'t find the answer to. How do I gr

9条回答
  •  暖寄归人
    2021-01-30 04:39

    In Slim 3.0 the following also works:

    routes.php

    require_once 'user.php';
    
    $app->get('/user/create', '\UserController:create');
    

    user.php

    class UserController
    {
        public function create($request, $response, array $args)
        {
            $username = $request->getParam('username'));
            $password = $request->getParam('password'));
            // ...
        }
    }
    

提交回复
热议问题