Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
HMVC request to a Rest Controller?
  • I have a controller(called a) that extends the REST controller. When I visit http://mysite.com/a/b I get the expected result (it's response is a simple array). However when use the code $output = Request::forge('a/b')->execute(); from controller(c) it returns a 404. Both a and c are located in app/classes.. Are there any reasons that shouldn't work? Thanks
  • swampiest wrote on Tuesday 7th of February 2012:
    I have a controller(called a) that extends the REST controller. When I visit http://mysite.com/a/b I get the expected result (it's response is a simple array). However when use the code $output = Request::forge('a/b')->execute(); from controller(c) it returns a 404. Both a and c are located in app/classes.. Are there any reasons that shouldn't work? Thanks

    I'm having a very similar problem now.
    I'm trying to call a REST controller that sits in a module from another controller in that module. No dice.
    $data['categories'] = \Request::forge('uploader/dataload/get_categories', false)->execute();
    
  • Those are two different issues. In the first case, URI requests go to action_methodname, REST calls go to get_methodname, post_methodname, etc. And if those not exit, it will fall back to action_methodname. In normal cases you can't call REST methods from the browser, as the methods aren't prefixed with 'action_'. In the second case, it's an HMVC call to a rest controller. At the moment, Request forges URI requests only, which means the REST controller doesn't see it as an ajax call. This is because the Input class operates global, and not per request. There is an issue open to fix this (it's on my todo list).

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion