General developer forum

Using locallib.php vs using classes

 
Picture of Mark Johnson
Re: Using locallib.php vs using classes
Core developersParticularly helpful MoodlersPlugin developers

That's a good point. I believe that page is the current info.

A quick search of the wiki for "locallib.php" suggests that these pages need updating to reflect current best practice:

https://docs.moodle.org/dev/lib.php
https://docs.moodle.org/dev/Libraries_Organization
https://docs.moodle.org/dev/NEWMODULE_Documentation

I'll do a quick update of these page while I'm at it, any improvements on what I write are welcome!

 
Average of ratings: -
Richard Jones
Re: Using locallib.php vs using classes
Particularly helpful MoodlersPlugin developersTesters

This might be something that could be added?

I have data handling functions and utilities for my sub-tables of an activity module (like saving and updating them). I want to put these in functions (classes?) if I feel they are too complex or long to go in the editing page. 

Are there naming conventions like all db handling methods go into one sub-folder (or page) and utilities in another? 

Or is that up to the individual developer just to use common sense?

 
Average of ratings: -
Davo
Re: Using locallib.php vs using classes
Core developersParticularly helpful MoodlersPlugin developers

If you are going to use a subfolder, then, to avoid clashes with future core Moodle class namespaces (e.g. the 'task' and 'event' subfolders), you should create your subfolders inside 'local', e.g. myplugin/classes/local/blah - after that, you're free to do what you want (and note that the use of 'local' is not enforced, just encouraged).

 
Average of ratings: Useful (1)
Picture of David Pesce
Re: Using locallib.php vs using classes
Plugin developers

Any idea when the example github repo (https://github.com/moodlehq/moodle-mod_newmodule) will be updated to reflect how plugins should be developed?


I'd like to start working on an xapi/cmi5 activity module and am getting a bit lost in the Moodle docs.


P.S. I've got a background in documentation. If someone can point me to scratch notes and/or provide a tutorial via webconference (I'll pay), I can update the docs.

 
Average of ratings: Useful (1)