Respect/Rest

if i can make request like this?

Closed this issue · 4 comments

hi
i want to make a request like this
xxx.com/A/B/C
it can route to the class A

class A{
public function B($C){}
}

so cool just like MVC
can i make request like this in Respect/Rest

It's possible. But I would like to see a more concrete RESTful use case before discussing a core implementation =) What do you have in mind?

Currently, even though we don't support this feature at the core, you can easily implement this by yourself if you need with something like this:

$router->any('/**', function($params) {
    $className = array_shift($params);
    $methodName = array_shift($params);
    $obj = new $className;
    return call_user_func_array(array($obj, $methodName), $params);
});

thanks its very cool , another way haha~

The factory option is also available to do what you are suggesting See the Controller section of the docs at around the end of the section.

This is a very basic example but the factory actually receives the params collection by reference which it may modify.
You are just starting to realize how awesome it is, keep digging and let us know what you find. =)

Closing issue no further discussions in 2 months.