Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
error action_index() or the controller after() method must return a Response object.
  • Hi guys/gals, Just starting out with fuelphp so thought I'd grab a tutorial recommend on this forum in another post over at http://net.tutsplus.com/tutorials/php/getting-started-with-the-fuel-php-framework/ Just started following and already hit a problem, the very first step says to create your own controller and echo hello world from it. But when I point my browser to the method I get this error: Fuel\Core\FuelException [ Error ]: Controller_Hello::action_index() or the controller after() method must return a Response object. Can anyone help me with this?
  • This tutorial is based on v1.0, and no longer current ( we're on 1.2 at the moment ). As the message says, action methods are now ( as of v1.1 ) required to return a Response object. Alternatively you can return a string or something that can be cast to a string, in which case FuelPHP will encapsulate it into a Response object for you. What is not acceptable is to return something else, and that includes not returning anything ( which actually returns null ). So, the official return is
    return \Response::forge('value to return');
    
    or alternatively
    return 'value to return';
    

Howdy, Stranger!

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

In this Discussion