Jump to content

How to include GuzzleHttpClient as dependency for ProcessWire Module?


Recommended Posts

I'm working on finishing AltTextGpt in order to publish it, but I need to figure out how to properly include its dependency on Guzzle.

I'm working on figuring out how to officially publish the module, and how to specify that it requires GuzzleHttpClient.

Edited by notplants
Link to comment
Share on other sites

  • notplants changed the title to How to include GuzzleHttpClient as dependency for ProcessWire Module?

Hi @notplants welcome to the forum and thx for your contribution!

There is no standard way of adding requirements. ProcessWire does not use composer or such. It is just a platform to run modules. How you add your dependencies basically is up to you. One option is to include it into your module. So you'd do composer require ... on your dev environment and then you add require vendor autoload to your module and that's it. That means it is super easy to install for anybody else, but that also means that if you (or anybody else) had multiple modules that require guzzle in the best case it would just be some overhead (as every module might ship a separate version of guzzle) and in the worst case you'd get conflicts.

Another option would be to create another module solely for adding guzzle to PW. That way several other modules could use the guzzle module and you'd have less overhead, but more to do during installation or maybe also more troubles as you need to keep versions compatible...

The third and in this case IMHO best option is to use WireHttp instead of guzzle unless you really need guzzle for the http requests?! WireHttp is part of the core so you get the best of option 1 and option 2.

  • Like 2
Link to comment
Share on other sites

Posted (edited)

@bernhard thanks for the welcome and the comprehensive list of options!

makes sense -- and I was not aware of WireHTTP before. I was able to change the module to use WireHTTP instead of Guzzle quite easily, so now no external dependency is needed. The changes have already been pushed to the github repo.

Edited by notplants
  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...