Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
instantiating a Model's class from tasks
  • Hi there, does anyone know how I can reference a Model's lass from within a task? having my class in /app/classes/model/Google/Adwords/myclass.php I try to reference it from my /app/tasks/mytask.php like this: $foo = new Model_Google_Adwords_Myclass(); But it fails as it searches within /Fuel/Tasks/Model_Google_Adwords_Myclass ... Any help would be appreciated. Best regards,
    Jonas
  • First, paths and filenames should be lower class, so /app/classes/model/google/adwords/myclass.php. And second, FuelPHP's classes are namespaced. If you load something from another namespace, you will have to tell the autoloader that. In this case, the task class lives in the "Fuel/Tasks" namespace, while your model lives in the global namespace.
    // prefix the class with a backslash to load from global
    $foo = new \Model_Google_Adwords_Myclass();
    

Howdy, Stranger!

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

In this Discussion