Re: HttpFactoryInterface maybe? (PSR-17)

2019-11-12 Thread Matthew Weier O'Phinney
On Mon, Nov 11, 2019 at 5:16 PM Anton Fedonjuk 
wrote:

> It's shortes and guarantees full support PSR-7, PSR-17:
> setHttpFactory(HttpFactoryInterface $factory);
> getHttpFactory(): HttpFactoryInterface;
>
> now:
> setRequestFactory(RequestFactoryInterface $factory);
> getRequestFactory(): RequestFactoryInterface;
> ...
> setUriFactory(UriFactoryInterface $factory);
> getUriFactory(): UriFactoryInterface;
>

We actually debated this when forming the specification, and decided
against it.

The rationale was that in most cases, you will need a subset of all
factories. As an example, in server-side applications, the only place
you'll generally need the request, URI, and/or uploaded file factories is
at the application entrypoint. And when you are in a handler or middleware,
you'll need the response factory, and _maybe_ the stream factory at most.
(The "maybe" part has to do with whether (a) you're returning any actual
content, and (b) whether you need special capabilities in your content
stream, vs. just writing to it. In that latter case, you'll likely be
depending on an _implementation_ anyways.)

It would be rare that you would ever need a factory that combines all
capabilities. Even with an HTTP client, generally speaking the consumer
will want the factories for creating a request, but the responsibility of
creating the response would be entirely up to the client itself. Even when
creating the request, quite often only a subset is necessary:
createRequest() can create the URI and body stream, and in most scenarios,
what they do is enough.

Our take was that we could try and second-guess which combinations would be
useful, but the list would become expansive, and users would be confused
about what they should type-hint on: should they hint on the most specific
they need, or one or more interfaces representing "union" types? We felt
users should indicate _what they need_, specifically.

That said: there's always the fig/http-factory-util package for managing
some of these, and our thought was that users could propose some of those
union types there. If those become widely used, we can create an additional
spec that codifies them.


> вторник, 12 ноября 2019 г., 2:01:44 UTC+3 пользователь Alexander Makarow
> написал:
>>
>> What would be the benefit having it?
>>
>> вт, 12 нояб. 2019 г., 00:28 Daniyal Hamid :
>>
>>> 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 
>>> and Nyholm
>>> 
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/php-fig/d1087758-ceac-4b9a-a1e2-107553d9c18c%40googlegroups.com
>>> 
>>> .
>>>
>> --
> 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/ebc77935-c27e-4604-9294-783010c0f2a0%40googlegroups.com
> 
> .
>


-- 
Matthew Weier O'Phinney
mweierophin...@gmail.com
https://mwop.net/
he/him

-- 
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/CAJp_myWEk2Jsgb2KMBNQawaiq6uz2cV%2BaMX4dEmEHe9cjdM52g%40mail.gmail.com.


Re: HttpFactoryInterface maybe? (PSR-17)

2019-11-11 Thread Daniyal Hamid
+1 Anton .. exactly!

Also, sorry can we continue the thread in the other post 
.

On Tuesday, November 12, 2019 at 12:16:42 AM UTC+1, Anton Fedonjuk wrote:
>
> It's shortes and guarantees full support PSR-7, PSR-17: 
> setHttpFactory(HttpFactoryInterface $factory);
> getHttpFactory(): HttpFactoryInterface;
>
> now:
> setRequestFactory(RequestFactoryInterface $factory);
> getRequestFactory(): RequestFactoryInterface;
> ...
> setUriFactory(UriFactoryInterface $factory);
> getUriFactory(): UriFactoryInterface;
>
> вторник, 12 ноября 2019 г., 2:01:44 UTC+3 пользователь Alexander Makarow 
> написал:
>>
>> What would be the benefit having it? 
>>
>> вт, 12 нояб. 2019 г., 00:28 Daniyal Hamid :
>>
>>> 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  
>>> and Nyholm 
>>>  
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/php-fig/d1087758-ceac-4b9a-a1e2-107553d9c18c%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
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/aeb82529-3bdd-4f19-a31f-d1bb73072a0f%40googlegroups.com.


Re: HttpFactoryInterface maybe? (PSR-17)

2019-11-11 Thread Anton Fedonjuk
It's shortes and guarantees full support PSR-7, PSR-17: 
setHttpFactory(HttpFactoryInterface $factory);
getHttpFactory(): HttpFactoryInterface;

now:
setRequestFactory(RequestFactoryInterface $factory);
getRequestFactory(): RequestFactoryInterface;
...
setUriFactory(UriFactoryInterface $factory);
getUriFactory(): UriFactoryInterface;

вторник, 12 ноября 2019 г., 2:01:44 UTC+3 пользователь Alexander Makarow 
написал:
>
> What would be the benefit having it? 
>
> вт, 12 нояб. 2019 г., 00:28 Daniyal Hamid  >:
>
>> 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  
>> and Nyholm 
>>  
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/php-fig/d1087758-ceac-4b9a-a1e2-107553d9c18c%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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/ebc77935-c27e-4604-9294-783010c0f2a0%40googlegroups.com.


Re: HttpFactoryInterface maybe? (PSR-17)

2019-11-11 Thread 'Alexander Makarow' via PHP Framework Interoperability Group
What would be the benefit having it?

вт, 12 нояб. 2019 г., 00:28 Daniyal Hamid :

> 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 
> and Nyholm
> 
> 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/d1087758-ceac-4b9a-a1e2-107553d9c18c%40googlegroups.com
> 
> .
>

-- 
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%2BFA5VU5YariK3w6yMPraky6zr1LVDfeJ4zT_xMZACMorFpdqg%40mail.gmail.com.