Code Monkey home page Code Monkey logo

Comments (3)

sagikazarmark avatar sagikazarmark commented on August 20, 2024

The usage of discoveries is covered in the general section.

do i simply need to call HttpAdapterDiscovery::find() and thats it?

Yes, it is that simple.

and for creating messages, i need the MessageFactoryDiscovery::find()->createRequest?

It is not specifically mentioned in the documentation, but IIRC the discovery classes contain docblock about the returned types. MessageFactoryDiscovery returns a MessageFactory which you can use to create messages. While discoveries has caching builtin, I suggest storing the discovered object internally in your class, so that you only have to call the discovery once.

and what is the uri factory for?

IIRC @ddeboer created that one, he specifically needed that and I had nothing to say against it.

the MessageFactory accepts a string as well (the doc is incorrect btw, it should state that it can also accept an UriInterface)

No, it is on purpose. The factory accepts string as well so you can create your request object directly without the need for creating an Uri object first. The other reason it is there is that every PSR-7 implementation differs: one accepts string in it's constructor, another doesn't. This tries to make it consistent: each accepts everything.

I think I answered all your questions. If you feel a PR is still necessary or you think you can improve the docs so that other people won't have to ask these questions again, please feel free to submit a PR.

from documentation.

dbu avatar dbu commented on August 20, 2024

The usage of discoveries is covered in the general
http://php-http.readthedocs.org/en/latest/discovery/#general section.

ah, right. hm but that is rather abstract to read. i will try to do a PR
with a little usage tutorial.

the MessageFactory accepts a string as well (the doc is incorrect
btw, it should state that it can also accept an UriInterface)

No, it is on purpose. The factory accepts string as well so you can
create your request object directly without the need for creating an Uri
object first. The other reason it is there is that every PSR-7
implementation differs: one accepts string in it's constructor, another
doesn't. This tries to make it consistent: each accepts everything.

okay, the doc mistake was in guzzle psr7 Request:
guzzle/psr7#35

from documentation.

sagikazarmark avatar sagikazarmark commented on August 20, 2024

Looking at the docs, there are code examples about using the specific discoveries as well:

http://php-http.readthedocs.org/en/latest/discovery/#http-adapter-discovery

Thank you for contributing!

from documentation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.