Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Can we extend module Controller with other Module controller?
  • Can we extend module Controller with other Module controller?
  • Yes, no problem.
    namespace Mymodule;
    
    class Thiscontroller extends Thatcontroller
    {
    }
    

    If they are not in the same module, you have to use the full namespace, and you have to make sure the module the parent controller is in, is loaded.
    namespace Mymodule;
    
    // load the module here it if's not autoloaded or loaded elsewhere
    \Module::load('othermodule');
    
    class Thiscontroller extends \Othermodule\Thatcontroller
    {
    }
    

    Note that it is considered bad practice to create dependencies across modules, so make sure you have a good reason for doing so.
  • i read in doc about admin_controller and public_controller create in classes controller and we can extend them to other admin and public controllers, so i though if we can do let me put and in module but getting error while extended module controller with other. [Solved]
    i have to put admin or public modules in always_load of config.
    [/Solved]

Howdy, Stranger!

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

In this Discussion