We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Best practice for shared library class between your add-ons

Development and Programming

Oskar Smith's avatar
Oskar Smith
33 posts
15 years ago
Oskar Smith's avatar Oskar Smith

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.php

both of which need access to the library class:

paint.php

I 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.php

But 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.php

And 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.

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
15 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

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.

       
Oskar Smith's avatar
Oskar Smith
33 posts
15 years ago
Oskar Smith's avatar Oskar Smith

Thanks Erik, will give it some thought.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.