Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Accessing internal REST API via Request::forge
  • To simplify my application I'm trying to build my application to run off its own REST API using the REST controller. If I funnel both external API calls and internal functionality through the API then I will reduce complexity and insure that the API functionality is always working as expected since the main app itself relies on the API. Maybe I'm just being too ambitious... ;) To call the internal local REST API from within my APP I'm doing the following:
    Request::forge('api/v1/test' )->set_method('POST')->execute( array( 'apples' ) )->response()
    

    The problem is that set_method() does not impact the method that is called. If I am accessing the page that calls this then it loads get_test() rather than post_test() based on calling set_method( 'POST' ). I see that in the core rest.php the following occurs:
    $controller_method = strtolower(\Input::method()) . '_' . $resource;
    

    This makes it look like there is no way to properly use the REST API directly from within my app via Request::forge(). Is there a workaround to this or am I SOL in doing this within FuelPHP? If what I am trying to do is not possible is there a better practice? I don't want to be making curl requests for sure. My other option is to just use the REST system to funnel API calls to other classes/methods.
    Thanks!
    P.S. A few site oddities I ran into here trying to make my first post: * Upon forum registration there is no confirmation, it only re-loads the registration page. I thought it didn't work but filling the form out again it informed me my account already existed. * Upon signing into the forum it redirects you to http://fuelphp.com instead of back to the forum. * In Chrome for Mac none of the forum formatting buttons work. Error console shows "Uncaught ReferenceError: insert_code is not defined ". Perhaps a hover title
    tag with explanations on how to manually use these features would be useful. I luckily figured it out guessing. :) * During preview emoticon icon images 404. Ex: http://fuelphp.com/forums/topics/new_topic/addons/default/themes/fuel/img/smileys/smile.gif * Line breaks in my message do not appear to apply during preview. We'll see if they stick once I submit this.
  • I've just checked the 1.3/develop codebase, and that uses the passed method correctly, so you might want to switch to that (or wait a few days, 1.3 is scheduled for release in a week or two).
  • Awesome! Thank you very much! :)

Howdy, Stranger!

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

In this Discussion