• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Guzzle6 for XenForo 2 1.0.0

No permission to download

Sim

Well-known member
#1
Sim submitted a new resource:

Guzzle6 for XenForo 2 - Provides a replacement Guzzle v6.x implementation for XenForo 2

Due to PHP version constraints, XenForo 2.0 implements Guzzle 5.3 rather than the current Guzzle 6.x

This XenForo 2.0 addon replaces the built in libraries with Guzzle 6.x and provides a test suite to ensure functionality is preserved.

The only reason you would want to install this addon is if you have other addons which require Guzzle 6.

Requirements

This addon requires PHP 5.5 or higher and only works on XenForo 2.0.x

The current release has been tested with XenForo 2.0...
Read more about this resource...
 

Sim

Well-known member
#3
Why don’t we request to upgrade in Xenforo Core? PHP version compatible?
Already had that discussion - refer to: https://xf2demo.xenforo.com/threads/guzzle-version.2524/

The devs have decided to be conservative with their supported PHP versions (5.4) and unfortunately Guzzle 6 requires a minimum of PHP 5.5

Now that we've moved v2.0 discussion back here, I'll start an official suggestion for Guzzle 6 support in the core - just to bookmark it.
 

Jake B.

Well-known member
#4
Wouldn't it be easier to just update any existing add-on use Guzzle 5? If you use this and have add-ons that expect the version of Guzzle that comes with XenForo i'd think it would cause issues wouldn't it? What benefit does Guzzle 6 have over 5?
 

Sim

Well-known member
#7
Wouldn't it be easier to just update any existing add-on use Guzzle 5?
Creating one addon which provides Guzzle 6 support is arguably less work than modifying 10+ addons to work with Guzzle 5. But as @NixFifty mentioned - I do have 3rd party packages which require Guzzle 6 creating the main driver here.

It's not as if Guzzle 6 is bleeding edge - 6.0 was released in May 2015, so it's well over 2 years old now.

If you use this and have add-ons that expect the version of Guzzle that comes with XenForo i'd think it would cause issues wouldn't it?
Yes, and that's the main gotcha that people will need to manage. However, once again - Guzzle 6 is the currently supported version and has been available for over 2 years now.

But that's also the case regardless of which version you use - managing dependencies is always tricky.

Given that Guzzle 5 and Guzzle 6 are fundamentally incompatible, you cannot mix libraries which depend on the other version.

But keep in mind that it's also more likely that people (like me!) will have already implemented XF 1.x addons to use Guzzle 6 because there was no dependency clash in previous versions of XF. So restricting XF 2.x to Guzzle 5 is actually a massive retrograde step from what we have now in XF 1.x

What benefit does Guzzle 6 have over 5?
If Guzzle 5 is working fine and you don't have external dependency requirements for Guzzle 6 - there's no real reason to upgrade and the version shipped with XF 1.5 will work fine. It's not as if it's broken or anything.

The main benefit to Guzzle 6 is that it is the version which is in active development and so will have improvements made which could help in some edge cases. There are a few new features which aren't available in Guzzle 5 - but for the typical simple use cases that XenForo integration would use, they are unlikely to be significant.

The other significant benefit moving forward (and the main reason for the incompatibilities with Guzzle 5), is the move to using PSR-7 as the HTTP message interface. This change to a standards-based approach allows Guzzle to work with any other library that utilises PSR-7 message interfaces. This will allow for a lot more interoperabilty as more people start to implement PSR-7.

Again though, that's not likely to have much impact on most people developing addons for XenForo - at least not in the short term.

At the end of the day - I would urge caution before using this addon of mine - if you don't have a compelling reason to move to Guzzle 6, then stick with the natively supported version of Guzzle 5 for now as this will be the less risky option.

I mainly built the addon for my own benefit to support all of my own internal addons and libraries which already use Guzzle 6 - and as an exercise in learning how XF2 addon development works.
 

Xon

Well-known member
#8
This will allow for a lot more interoperabilty as more people start to implement PSR-7.
PSR-7 is the sort of wonky standard I've come to expect from php-fig (php core is doing a lot better these days)

Explicitly mutable output body, but everything else trying to be immutable. You get all sorts of wonky insanity with the fact the PSR-7 is ultimately trying to wrap a mutable output stream with a series of out-of-date immutable objects.

This doesn't matter too much if you just construct your request at once and are talking to an API with small amounts of data. But using that sort of design for a php page request/response life-cycle? Hell no.
 
Last edited:

Sim

Well-known member
#9
Yeah, when you understand the fairly fundamental changes that had to be made to the way Guzzle operates to accommodate the immutable request objects - it does start to make you scratch your head a little trying to work out why bother.

I suspect that the whole immutable thing is trying to pander to a subset of developers who like to follow certain architectural patterns which prefer to deal only in immutable objects. I started to do some work with message busses in the Laravel space and they were all about immutable objects - and I get the point when dealing with small atomic chunks of information, but it becomes stupidly cumbersome when dealing with anything complex.

Some of my own libraries were written with immutable request objects and you end up with such stupidly huge constructor argument lists or such complex nested object structures that I think it just makes your code unreadable - all to just try and enforce a few rules when constructing objects.

One example is my API wrapper for domain/hosting provider Synergy Wholesale - take a look at some of the parameter lists in the request objects!

Yes, it is (by design) impossible to create an incorrect request - but it also makes your code rather horrible.
 
Last edited:

oO5 Dynasty

Well-known member
#13
Because they wanted to support PHP 5.4 as a minimum while Guzzle 6 requires PHP 5.5 as a minimum.

Refer to this discussion: https://xf2demo.xenforo.com/threads/guzzle-version.2524/
That was a pretty deep thread.
So i do not know anything about php. I do get what you was saying in that thread. Also get what the xenforo staff was saying.
So what my question is, what does higher php provide to websites, or xenforo websites?
This is what is shown in my cpanel http://prntscr.com/go8rqg
What would be a reason for me to change the version of php?
 

Chris D

XenForo developer
Staff member
#14
The primary reason that the minimum requirement is so low is that so many people are still using old versions. If people embrace newer PHP versions then so would we.

Despite our minimum requirements being so low we would actually recommend you use PHP 7.0 or 7.1. our code may not exploit some of the functional improvements in newer PHP versions but we do ensure the code is compatible and newer PHP versions do perform much better, are more stable and more secure. So generally as long as all the sites you run are compatible keep your installed PHP version as high as possible.
 

oO5 Dynasty

Well-known member
#15
The primary reason that the minimum requirement is so low is that so many people are still using old versions. If people embrace newer PHP versions then so would we.

Despite our minimum requirements being so low we would actually recommend you use PHP 7.0 or 7.1. our code may not exploit some of the functional improvements in newer PHP versions but we do ensure the code is compatible and newer PHP versions do perform much better, are more stable and more secure. So generally as long as all the sites you run are compatible keep your installed PHP version as high as possible.
So before I update my version are their any warnings I should be aware of. Like will it effect add-ons I have installed. Will things just stop working or will it just update to the higher version and I wont see any effects.
 

Chris D

XenForo developer
Staff member
#16
Most add ons should be compatible but if you have any issues you should just deal with them as they come up. I can't recall many add on issues resulting from PHP 7.0. Widget Framework was one but that has been updated.

At this point if you have any further questions, start a new thread as we're off topic now.
 

Floyd R Turbo

Well-known member
#17
Forgive the stupid question but googling this didn't really help me understand Guzzle...can someone give me a few examples of what can be done by using Guzzle + XF?
 

Chris D

XenForo developer
Staff member
#18
Guzzle is already included and used by XF.

It's a HTTP client. So anything that makes a HTTP request from your server to another server (verifying a CAPTCHA, making payments, anti-spam etc) is made through Guzzle.

The version included in XF2 is Guzzle5 because it still supports XF2's minimum version, PHP 5.4.

This has been released by @Sim to make XF2 use Guzzle6 which we can't include because it isn't compatible with PHP 5.4.

The only reason really to use this is if you already have custom code (such as Sim did) which already used Guzzle6. For everyone else, just ignore it :)
 

oO5 Dynasty

Well-known member
#19
Guzzle is already included and used by XF.

It's a HTTP client. So anything that makes a HTTP request from your server to another server (verifying a CAPTCHA, making payments, anti-spam etc) is made through Guzzle.

The version included in XF2 is Guzzle5 because it still supports XF2's minimum version, PHP 5.4.

This has been released by @Sim to make XF2 use Guzzle6 which we can't include because it isn't compatible with PHP 5.4.

The only reason really to use this is if you already have custom code (such as Sim did) which already used Guzzle6. For everyone else, just ignore it :)
Very well explained!
 

Sim

Well-known member
#20
The only reason really to use this is if you already have custom code (such as Sim did) which already used Guzzle6. For everyone else, just ignore it
I'll just highlight this last sentence again because it is very important.

The only reason really to use this is if you already have custom code which already used Guzzle6. For everyone else, just ignore it.

Do not install this addon unless you really know that you need it.

While I am testing each official release to ensure that most core functionality should work with my addon installed (and will try and fix it if I've missed anything) - you should be aware that 3rd party addons which utilise the built-in Guzzle 5 functionality could potentially break with this addon installed due to the incompatibilities between Guzzle 5 and Guzzle 6.