PHP Tonic Services - using the same verb more than once in one service

I started to learn the Tonic Restful Services framework , and I really think this is a very good structure. The problem is that I can not find many resources, except for examples, to see possible ways to use them.

I would like to know, for example, if I can use the POST verb more than once in one resource, and if there is any annotation that could allow me to do this. For example, JAX-RS has an @Action annotation.

I really don't have much experience with REST or PHP, so I really need your help.

Thanks in advance.

+3
source share
1

, . , . ...

- .

   /**
     * Handle a POST request for this resource
     * @param Request request
     * @return Response
     */
    function post($request) {

        if (isset($_POST['method'])) {
           return $this->$method($request, $name);
        }

    } 

    function post_one($request) {
       // your code here
    }

    function post_two($request) {
       // your code here
    }

    //...and so on...

, , -

if (method_exists('controller_name', 'method_name'));

. http://php.net/manual/en/function.method-exists.php

+1

Source: https://habr.com/ru/post/1781429/


All Articles