I have been asked to perform some updates to a site that uses FuelPHP(v 1.6). The current site defines a Base controller that extends the core controller. It is located in the app/classes/base.php file. All other controllers extend Base and are located in the app/classes/controller directory. Because of new functionality that has been requested, I need to change the controllers to hybrid to expose the rest functionality. Since all controllers are derived from Base, I think I should just be able to make Base extend from Controller_Hybrid. I have tried this and get an immediate error when trying to access pages.
The error says "Creating default object from empty value" at line 67 of COREPATH/classes/controller/rest.php. I would appreciate any help or guidance on how to resolve this issue or if there is a better way to convert to hybrid controllers.
The Hybrid controller is a combination of the Template and the Rest controller. If the Base would have used Template, then the swap would have been easy and painless.
But you say the Base controller currently extends \Controller, it makes things more complicated because that means you will have to deal with converting the current way of generating HTML output to using the template controller.
if your task is to provide the application with a REST API, the best advise is to stay clear of the Hybrid Controller (which is a bad thing imho), but design a separate API with controllers that use Controller_Rest as a base controller. Much easier to maintain, and to upgrade in the future, if you design and version your API correctly.
// Some Methods cant have a body $this->request->body = null;
which means $this->request does not contain a valid request object. Which is very weird, since that is created in the constructor of it's parent class, \Controller.
Does the app by any chance define it's own \Controller class in app/classes, or overload the core class, with a different constructor?
I think the best approach for me would be to leave everything as is and create the new API using Controller_Rest as the base controller.
For the other question related to definition of it's own \Controller class, the constructor does not appear to be overloaded and the base.php file is the only file in the app/classes directory and it just extends the \Controller class.
For the last comment, I do not need to use the Hybrid Controller, I just needed the REST API and thought Hybrid would be best so that I could keep the existing functionality.