Writing API clients with HTTPlug
PSR-7 defines common interfaces for HTTP requests and responses. But libraries that need to send HTTP requests need more than that. HTTPlug defines an interface for HTTP clients and provides adapters for existing clients like Guzzle, as well as a plugin system operating directly on PSR-7. This tool chain allows to build API clients that do not depend on a specific HTTP client at all. This workshop by two of the main authors of HTTPlug will cover:
- Working with PSR-7 request and response
- Using HTTPlug and the MessageFactory
- Bootstrapping clients explicitly or with Puli
- Using the PHP-HTTP plugin system
- Strategies for writing an API client
- Story ark of developping a little application that becomes more and more powerful.
- Have a simple HTTP server API to write against. (Do not assume internet is working)
- Integrate in the summer camp vagrant box
- PSR-7 introduction, working with request / response, immutability: CRUD todo items.
- Using the factories to send a request (mention the upcoming PSR)
- Adding plugins:
- enable logger plugin
- enable basic auth feature and add authentication plugin.
- Start with simple arrays, but then use a Serializer: Jane / Symfony Serializer / JMS Serializer ?
- Build models, use content negotiation (enable feature flag on server)
- Writing a reusable API client library