Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
how i can execute a module and get output?
  • I have a module names mymodone ,  i want to load and execute method (action) mymethodone of that module and get output html, how i can do that? is there any thing like module::run('modulename/....') ?
  • HarroHarro
    Accepted Answer
    Calling code cross-context is a bad thing to do, as it will destroy any loose coupling between components.

    You call a controller using an HMVC call:

    try
    {
        // assuming the method called returns HTML
        $html = \Request::forge('mymodone/controllername/mymethodone')->execute()->response()->body();
    }
    catch (\HttpNotFoundException $e)
    {
        // the requested route does not exist
    }

    which uses routing to decouple caller and callee. This way you can route the request to another action without changing any code, rename or remove the module, and your app will continue to work.
  • i want to create some widgets,  small applications such 'site state' , 'login or user info' , 'fast contact us' ,... this widgets are complete but small modules, what is best way to implement this?
  • As I described, using an HMVC call.

Howdy, Stranger!

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

In this Discussion