I'm trying to develop a J2Store app for the shipping broker FlagShip, using their SDK found here. (Their SDK essentially provides objects which handle calls to their API so that the developer doesn't need to fiddle with gritty details.) This is a challenge to me because as far as I can tell there are no Joomla extensions for a shipping broker that I can model my extension on, and I'm still rather new to Joomla development.

In order to make FlagShip's SDK available to my module's code I had to install it via Composer (which I also had to install) in my test site's project directory; Composer also installed a number of dependencies that the SDK needs (i.e. it is not a stand-alone library). Then in my module entry point I just had to add the line require_once './vendor/autoload.php'; and then I'm able to include their SDK objects via use Flagship\Shipping\Flagship; etc.

It doesn't seem ideal to have to do this installation process for every site that wants to use my module, so my question is this: is there a proper Joomla way to package FlagShip's SDK into my module? Is this a case where I would want to use an installation script?

I also feel like it's weird that require_once './vendor/autoload.php'; works, but require_once JURI::base() . 'vendor/autoload.php'; does not, even though the vendor folder I'm looking for is in my website's root folder. Why is that? Isn't there a potential ambiguity by using "./"?

edit: I just realized this is potentially a duplicate of this question, but I'm not sure about the specifics of using libraries vs installing SDKs. Is it the same thing? Can I just copy their SDK files into a "libraries" folder in my extension and just import it from there? How do I make sure it's up to date and that all the dependencies are included?

  • Hello, You should put it in our on vendor directory like \libraries\ourcomponent\vendor . You need to run install composer from this directory to have all depencies, when you launch the build of your extension the directory \libraries\ourcomponent\vendor needs to be inclued too. – user3533235 Jun 10 '19 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.