php-http / message-factory

Abandoned: Httplug Factory interfaces for PSR-7 HTTP Message
http://php-http.org
MIT License
1.38k stars 10 forks source link

Virtual package #13

Closed sagikazarmark closed 8 years ago

sagikazarmark commented 8 years ago

I was thinking about creating a virtual package, and I am going to explain here, why I won't introduce one:

The actual dependency is the PSR-7 implementation, not the message factory implementation. In an ideal case, message implementations should have their own factories implementing these interfaces. If it is not possible, we should have them either in discovery or bridge packages:

https://github.com/mekras/httplug-diactoros-bridge

Bridge packages could even be extracted from discovery to make them usable separately.

To sum up: factories belong to implementation. We should rely on implementations and automatically provide factories, when they don't (served by the discovery layer).

dbu commented 8 years ago

agreed.

Nyholm commented 8 years ago

Yes. We should not use a virtual package for factories

sagikazarmark commented 8 years ago

Should we mention this in the documentation?

dbu commented 8 years ago

why not? but we need to be sure of the target audience. what does a consumer of a generic library want to know? what does a library author want to know? implementation reasoning beyond that is only relevant for php-http contributors. we might create a page in the doc for that, also with the reasoning you explained on slack today:

From the three package (httplug, promise, message-factory) you actually need to require one, possibly two

​[11:47] httplug is required

​[11:47] message-factory is recommended, if you want to support multiple message implementations

​[11:48] For example in case of guzzle you probably don’t need it

​[11:48] promise is required by httplug, you don’t need to explicitly required

​[11:48] now comes the reasoning

​[11:49] We decided to decouple promise from the main package so that it is easier to decouple when a PSR or a sane standard is created

​[11:49] we just have to deprecate our own and require the standard (with a major version change)

​[11:50] we just need to rewrite some docblocks, but the contract does not really change in this case

​[11:50] also, the promise package is used to create some promise helpers in the client -utils package without requireing httplug

​[11:51] The message factory contract should actually be required by the message implementations

​[11:52] I am already preparing a PR to guzzle/psr7 to use our message factory interfaces. In case of diactoros it is much harder as it would introduce some BC breaks

​[11:53] Also, message factory is purely PSR-7 related, not httplug

​[11:56] from a reusable library point of view, httplug is your only dependency, it is the client implementation’s decision whether it wants to support multiple message implementations through message factories or just one

​[11:58] Hope this helps to understand the workflow, which I admit: is a bit complicated

​[11:58] I am open to any suggestions how we could make it simpler

sagikazarmark commented 8 years ago

Agree, I guess we have to improve our docs from this point of view as well.

dbu commented 8 years ago

okay. do we move this issue to the doc repository?

sagikazarmark commented 8 years ago

:+1:

dbu commented 8 years ago

https://github.com/php-http/documentation/issues/40