A proposal for a 'locallib' folder

A proposal for a 'locallib' folder

by lior gil -
Number of replies: 4
Picture of Core developers

Hello everyone.

I haven't been here for a while so I don't know if this idea ever came up.

We have a large amount of local plugins for many purposes and sometimes during the work we end up developing tools and classes that are useful in other places. However, there isn't a fitting place for them and we end up placing them in the active theme folder or call them from other local plugins.

So from this need came the idea of creating a structured location for these files that will function the same as the lib folder, only for our local needs, hence the locallib title.

It will come with a matching $CFG->locallibdir globa setting.

Has anyone already tried this approach? Do you think it's something that can become a part of the Moodle structure? 

Average of ratings: -
In reply to lior gil

Re: A proposal for a 'locallib' folder

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Can't you do that already with the 'local' folder? i.e. have a 'Toolbox local plugin' and have your other plugins use / depend on that?
Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: A proposal for a 'locallib' folder

by lior gil -
Picture of Core developers
This is what we have right now, a local plugin that is pretty much just a repository. I just don't think this is a proper way to use a plugin.
Creating a known location for non-core lib files will not only simplify the developing workflow but will also make it easier to share with other developers.
Here's a case scenario:
Someone has to alter very large tables. The process takes a long time, too long for a standard upgrade run, so the solution is through a script. This developer looks in the available plugins list, under 'non-core lib', and find a class someone wrote just for this purpose, to handle large table alternations through CLI, including exception handling, formatted output etc.
So instead of downloading a local plugin that only holds the class (or copying part of the code to put it somewhere), the developer can just get the actual class and use it, and of course update it when a new version is available.
In reply to lior gil

Re: A proposal for a 'locallib' folder

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

I just don't think this is a proper way to use a plugin.

Quite opposite really. I have to agree with Gareth here. This is actually a very valid use-case for plugins - admin tools or local plugins. You can have them versioned, you can declare dependencies, you can easily share them with others etc. There is nothing wrong about a plugin whose solely purpose is to only provide a class or act as a wrapper for an upstream library package.

In reply to David Mudrák

Re: A proposal for a 'locallib' folder

by lior gil -
Picture of Core developers
Yeah you're right. Since this post we has a brainstorm and decided to go with the local plugin that will be a well-structured repository, Thanks.