Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Can't use normal php classes in oil tasks?
  • I have a Fuel task that iterates through directories and adds/updates files to a MySQL database. It uses RecursiveDirectoryIterator and RecursiveIteratorIterator, but apparently this is illegal.

    I keep getting this error when running 'php oil refine updatedb' (file is fuel/app/tasks/updatedb.php):

    PHP Fatal error:  Class 'Fuel\Tasks\RecursiveDirectoryIterator' not found in /var/www/vhosts/basketbuild.com/sitebeta/fuel/app/tasks/updatedb.php on line 15
    Error - Class 'Fuel\Tasks\RecursiveDirectoryIterator' not found in APPPATH/tasks/updatedb.php on line 15

    Obviously RecursiveDirectoryIterator is not a Fuel class, it's a standard PHP class. Why is it looking for a Fuel class and how can I fix this?

    Tried searching through the docs but found nothing helpful.

    Here is the full code: https://gist.github.com/drewwalton19216801/5967104
  • HarroHarro
    Accepted Answer
    Standard classes live in the global namespace.

    Since your task is namespaced, you'll have to use \RecursiveDirectoryIterator, prefix it with a backslash to indicate you want to use it from global.

Howdy, Stranger!

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

In this Discussion