Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
tasks :: how to include a model into tasks ?
  • TASKS question: How to call "mymethod" from:
    classes/modules/directory1/mymodule
    
    in Task1 :: method1? EXAMPLE that does not work:
    namespace Fuel\Tasks;
    
    class Task1 
    {
    
        public function method1()  
        {
    
            // add the module MyModule to FuelPHP
            Fuel::add_module('directory1/mymodule');
    
            // calling the module class
            \directory1\mymodule\myclass::mymethod('parms');
        }
    
    How should it be correct without using include_once('/path/to/directory1/mymodule') ? Thank you Jozef
  • What is the namespace of the model? Once you've run add_package() it will be available like always, with the full classname though and starting with a backslash as the file itself is in Fuel\Tasks and you need to start from global:
    \Model_Example::count(); // take a model from the app
    
    \Mypkg\Model_Two::query()->get(); // take a model from package Mypkg
    
  • Thank you Jelmer. The model has no namespace. Should it has the same as the TASK? Actually I see, I am mixing in my question tho things: models and modules. The question should be what is the best way to include classes in TASKS from modules and models without using include_once. I think the front-backslash like \Model_Example::count(); should solve my problem.

Howdy, Stranger!

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

In this Discussion