Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Fragment PSR-7, Co to właściwie oznacza...
trzczy
post
Post #1





Grupa: Zarejestrowani
Postów: 460
Pomógł: 49
Dołączył: 5.06.2011

Ostrzeżenie: (0%)
-----


Znam trochę angielski, ale jakoś nie rozumiem tego fragmentu PSR-7. A ciekawi mnie on, bo zastanawiam się, czy powinno się implementować MessageInterface również, kiedy implementuje się RequestInterface. Wydaje mi się, że w tym fragmencie o tym jest. Proszę o wytłumaczenie tego fragmentu:


'
Both Psr\Http\Message\RequestInterface and Psr\Http\Message\ResponseInterface extend Psr\Http\Message\MessageInterface.

While Psr\Http\Message\MessageInterface MAY be implemented directly, implementors SHOULD implement Psr\Http\Message\RequestInterface and Psr\Http\Message\ResponseInterface.

'

Z góry dziękuję
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
lukaskolista
post
Post #2





Grupa: Zarejestrowani
Postów: 872
Pomógł: 94
Dołączył: 31.03.2010

Ostrzeżenie: (0%)
-----


Cytat
Skoro podawany przez FIG RequestInterface rozszerza MessageInterface, to nie powinno się stosować RequestInterface bez MessageInterface.
Nie tyle "nie powinno się stosować", po prostu nie da się tego niezastosować (IMG:style_emoticons/default/smile.gif)

Od początku:
Masz 3 intarface'y:
MessageInterface
RequestInterface extends MessageInterface
ResponseInterface extends MessageInterface

Albo robisz 1 implementację MessageInterface i używasz jej dla zapytań i odpowiedzi, albo robisz 2 implementacje (jedna RequestInterface i jedna ResponseInterface) i implementacji RequestInterface używasz do przyjmowania zapytań, a implementacji ResponseInterface używasz do zwracania odpowiedzi.

Edit:
W końcu znalazłem: zend-diactoros
Zwróć uwagę na klasy Request i Response - implementują odpowiednie interface'y i nigdzie nie ma bezpośredniej implementacji MessageInterface, ponieważ inteface'y Request i Response ją wymuszają.

Ten post edytował lukaskolista 31.01.2016, 12:08:04
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 10.10.2025 - 09:25