Skip to content

Conversation

@barryvdh
Copy link
Member

  • Since Guzzle supports ServerRequestFactory from Globals, we don't need to use Diactoros.
  • The HTTP Factory PSR seems to be stalled, so I created my own factory with similar methods.
  • The HttpClient should just be sending methods, not other PSR factories. So split those out.
  • Add shortcuts for get/post/put etc in an AbstractClient, for easier upgrade and readability.
  • Use static calls for the factories, as I don't think these need to be changed in user-land and don't require state.

I think this cleans up the factories pretty well, as we don't need to inject a lot of dependancies everywhere. Note that we do require on Guzzle/psr7 for this, but only internally, so we can upgrade to other PSR-7 factories when required.

@harikt
Copy link

harikt commented Oct 24, 2016

The HTTP Factory PSR seems to be stalled, so I created my own factory with similar methods.

Do you know there exists https://github.com/http-interop ? It has different factories implementation also.

@barryvdh
Copy link
Member Author

Yes, that isn't stable or widely adopted yet.

@harikt
Copy link

harikt commented Oct 24, 2016

@barryvdh you can point to a release https://github.com/http-interop/http-factory/releases .

Not widely adopted is for it is WIP . But you should consider discussing with @shadowhand , @nyamsprod for they also part of League and they have some of the implementations based on it. ( https://github.com/bakame-php/http-client ) .

@barryvdh
Copy link
Member Author

@barryvdh you can point to a release https://github.com/http-interop/http-factory/releases .
Yes, but that's still a 0.1 release, and PSR-17 is not yet accepted.

There also is https://github.com/php-http/message-factory from @sagikazarmark and other, which at least is stable, but also not widely adopted yet.

I could see myself adding a php-http Client, besides the default Guzzle one. But not sure how relevant a Http Factory abstraction is. What would be the main benefit, avoiding duplicate PSR-7 libraries? Perhaps also avoid package lock-in, although we don't expose the internals, so should be able to upgrade without breaking BC..

@harikt
Copy link

harikt commented Oct 24, 2016

sure 👍 . Thanks for the information.

@barryvdh
Copy link
Member Author

barryvdh commented Oct 24, 2016

I did some more reading, and I do kind of like both projects, but the problem is that:

  • php-http/message-factories: seems temporary solution until PSR-17 is released, and will then be deprecated: Contribute to http-interop php-http/message-factory#32
  • http-interop: Seems to be what will become PSR-17, but as they are not stable enough yet, also bound to break.

Due to the problems of requiring external interfaces now (Guzzle 3 Http client), I would really like to be sure the interface is here to stay for a good amount of time and otherwise use our own interface/class. And we really can't keep waiting for another half year.

@nyamsprod
Copy link
Member

@barryvdh exactly, the http-interop for the factory is nearly complete (don't be distracted by the 0.1.0 tag) so If I were to consider one of them I would go with the http-interop interfaces but @SHADOWAND may better answer this question. What is sure is that whatever changes may happen in the factories adding a "simple" wrapper around the current interface will solve the issue.

@sagikazarmark
Copy link
Member

I agree with @nyamsprod given PSR-17 is finished within a certain time.

php-http/message-factories: seems temporary solution until PSR-17 is released

That is not correct, we started the project way earlier than PSR-17 was proposed. As such, many of our projects rely on it, so we are not going to drop the support for it. Also, I am planning to provide bridges in both direction, so new software can use the old interfaces, and an old software can use the new implementations.

@barryvdh
Copy link
Member Author

barryvdh commented Oct 24, 2016

That is not correct, we started the project way earlier than PSR-17 was proposed. As such, many of our projects rely on it, so we are not going to drop the support for it.

Okay apologies, I meant that it seems that php-http/message-factories is already planned on being deprecated based on php-http/message-factory#32 (comment)

3 Once this proposal reaches standard phase, deprecate this factory package and recommend PSR-17

So while it might still receive support, it would be better to follow the 'official' one :)

@sagikazarmark
Copy link
Member

Okay apologies

No problem, just wanted to provide you correct information.

@barryvdh barryvdh merged commit 6febd19 into 3.0 Nov 7, 2016
@barryvdh barryvdh deleted the 3.0-httpfactory branch November 7, 2016 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants