Modern Moodle code uses automatic class loading to make sure that all relevant classes + the functions contained in them are loaded when they are needed. However, there is still a lot of older functionality which is not written in such a way, so you need to make sure you require the correct library files (usually you find out about this at the point when an 'undefined function' error occurs ...).
General developer forum
create_course debugging help
This discussion has been locked so you can no longer reply to it.