Skip to content

Document the most common usage of HTTPlug #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion httplug/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,22 @@ Create a file ``demo.php`` in the root folder and write the following code::
<?php
require('vendor/autoload.php');

TODO: create client instance with discovery and do some requests
use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\MessageFactoryDiscovery;

$client = HttpClientDiscovery::find();
$messageFactory = MessageFactoryDiscovery::find();
$homeResponse = $client->sendRequest(
$messageFactory->createRequest('GET', 'http://httplug.io')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No TLS :'(

);

var_dump($homeResponse->getStatusCode()); // 200, hopefully

$missingPageResponse = $client->sendRequest(
$messageFactory->createRequest('GET', 'http://httplug.io/missingPage')
);

var_dump($missingPageResponse->getStatusCode()); // 404

Using an Asynchronous Client
----------------------------
Expand Down