Hello all. I was wondering what other people’s opinions were on the best way of organising directory structure for shared libraries between your plugins. What I mean by this is if I have a set of similar add-ons (let’s say plugins to keep it simple) that are all related but perform slightly different actions or serve different purposes and all need to share a library class. e.g.
third_party/paint_widget_black/pi.paint_widget_black.php
third_party/paint_widget_yellow/pi.paint_widget_yellow.phpboth of which need access to the library class:
paint.phpI could put a copy in each add-on directory, i.e.
third_party/paint_widget_black/libraries/paint.php
third_party/paint_widget_yellow/libraries/paint.phpBut that means I now have two copies of the class floating around. I could also put it in the main Codeigniter library directory, but that feels to me like going outside what Ellislab meant to happen.
At the moment, I’m instead putting the library file in a themes directory. e.g.
themes/third_party/shared_paint_themes/libraries/paint.phpAnd calling it from my add-ons using:
$this->EE->load->library('../../../themes/third_party/shared_paint_themes/libraries/paint');But I don’t think the themes directory was put there for Class files, more for display elements etc.
So the question is, where is the correct place to put shared library files that can be used by Plugins, Fieldtypes, Modules etc.
For the record, in my particular case I’m actually developing a set of Fieldtypes with a shared library file to handle Image resizing and transfer to Amazon S3.
Any opinions welcome! Thanks.
I don’t think this is really addressed much in EE. The only example I can give you is Solspace who now ships add-ons with the Bridge directory (essentially it’s just CI).
I personally would just include a version in each add-on to keep it simpler on the user installing the package. You then avoids steps like “if directory <X> does not exist, create it; if it does exist be sure you upload file <Y> and that you have the latest version which is <Z.3>.”
It adds more time on the developer, but it’s the route I’d take personally.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.