What do you mean by autodetect?

There are interfaces for factories already. You can type hint as necessary,
you can replace implementation. It already promotes creating message via
individual interfaces such as ResponseFactoryInterface. It's not a good
idea to inject general HttpFactoryInterface and then use only one part of
its methods. It violates single responsibility principle.

вт, 12 нояб. 2019 г., 01:14 Daniyal Hamid <daniyal.ha...@gmail.com>:

> @Alexander Makarow asked: "What would be the benefit having it? "
>
> So, the problem this would solve is; imagine a use case, for example with
> a static http factory that tries to auto-detect an http factory
> implementation (such as Nyholms' or Guzzles'). Having an
> HttpFactoryInterface would serve the following benefit in such a use-case:
>
> 1. If the developer wanted to add his own factory, the
> HttpFactoryInterface would allow type hinting;
> 2. We could ensure an HttpMessageFactory implementation always has all the
> required factory methods to create http message related classes;
> 3. Implementations (such as Nyholms' or Guzzles') could easily be
> swappable;
> 4. It promotes ease of use for creating http messages.
>
> PS: @alexander Sorry, I ended up creating a duplicate post, the one you
> replied to I deleted, so I'm posting the reply here.
>
> On Monday, November 11, 2019 at 11:32:23 PM UTC+1, Daniyal Hamid wrote:
>>
>> Hi,
>>
>> I was wondering if it would be a good idea to create an
>> HttpFactoryInterface class that basically is an amalgamation of all PSR-17
>> interfaces, something like:
>>
>> interface HttpFactoryInterface extends
>>     RequestFactoryInterface,
>>     ResponseFactoryInterface,
>>     ServerRequestFactoryInterface,
>>     StreamFactoryInterface,
>>     UploadedFileFactoryInterface,
>>     UriFactoryInterface
>> {
>> }
>>
>>
>>
>> Guzzle <https://github.com/guzzle/psr7/blob/master/src/HttpFactory.php>
>>  and Nyholm
>> <https://github.com/Nyholm/psr7/blob/master/src/Factory/Psr17Factory.php> 
>> already
>> have HttpFactories as such so maybe it's a good idea to add such an
>> interface?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "PHP Framework Interoperability Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to php-fig+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/php-fig/f4f25988-528d-4b81-be83-d74d8898b3e6%40googlegroups.com
> <https://groups.google.com/d/msgid/php-fig/f4f25988-528d-4b81-be83-d74d8898b3e6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to php-fig+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/CA%2BFA5VVN7Sxc97DyEOZWEBnv9oFvYwfVsMg1US2L2UZhg%2B6ZCg%40mail.gmail.com.

Reply via email to