Skip to content

Restructure docs #52

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
File renamed without changes.
20 changes: 9 additions & 11 deletions docs/httplug/index.md → docs/httplug.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ In both cases, the `Http\Client\HttpClient` provides a `sendRequest` method to s
and returns a PSR-7 `ResponseInterface`or throws an exception that implements `Http\Client\Exception`.

There is also the `Http\Client\HttpAsyncClient` which provides the `sendAsyncRequest` method to send
a request asynchronously and returns a `Http\Client\Promise`.
a request asynchronously and returns a `Http\Promise\Promise`.
Copy link
Contributor

Choose a reason for hiding this comment

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

did this fix make it to master?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope

Copy link
Contributor

Choose a reason for hiding this comment

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

#61


The promise allows to specify handlers for a PSR-7 `ResponseInterface`
or an exception that implements `Http\Client\Exception`.


<p class="text-warning">
Contract for the `Http\Client\Promise` is temporary until
!!! warning "Warning:"
Contract for the `Http\Promise\Promise` is temporary until
[PSR is released](https://groups.google.com/forum/?fromgroups#!topic/php-fig/wzQWpLvNSjs).
Once it is out, we will use this PSR in the main client and deprecate the old contract.
</p>


See the [tutorial](tutorial.md) for a concrete example.
See the [tutorial](httplug/tutorial.md) for a concrete example.


## HTTPlug implementations
Expand All @@ -37,7 +35,7 @@ There are two kind of implementations:
- [php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation):
the synchronous implementation that waits for the response / error before returning from the `sendRequest` method.
- [php-http/async-client-implementation](https://packagist.org/providers/php-http/async-client-implementation):
the asynchronous implementation that immediately returns a `Http\Client\Promise`,
the asynchronous implementation that immediately returns a `Http\Promise\Promise`,
allowing to send several requests in parallel and handling responses later.

Check links above for the full list of implementations.
Expand All @@ -48,7 +46,7 @@ Check links above for the full list of implementations.
When writing an application, you need to require a concrete
[implementation](https://packagist.org/providers/php-http/client-implementation).

See [virtual package](virtual-package.md) for more information on the topic of working with HTTPlug implementations.
See [virtual package](httplug/virtual-package.md) for more information on the topic of working with HTTPlug implementations.


## Installation in a reusable package
Expand Down Expand Up @@ -84,10 +82,10 @@ You should however always accept injecting the client instance to allow the user
You can find an example in the [Discovery Component](/components/discovery) documentation.

Users of your package will have to select a concrete adapter in their project to make your package installable.
Best point them to the [virtual package](virtual-package.md) howto page.
Best point them to the [virtual package](httplug/virtual-package.md) howto page.

To be able to send requests, you should not depend on a specific PSR-7 implementation,
but use the [Message Factory Component](/components/message-factory) system.
but use the [Message Factory Component](message-factory.md) system.


### Framework Integration
Expand All @@ -108,4 +106,4 @@ which in most cases affected every adapter as well).

In 2015, a decision has been made to move the library to it's own organization, so PHP HTTP was born.

See [migrating](migrating.md) for a guide how to migrate your code from the Ivory adapter to HTTPlug.
See [migrating](httplug/migrating.md) for a guide how to migrate your code from the Ivory adapter to HTTPlug.
File renamed without changes.
40 changes: 25 additions & 15 deletions docs/components/authentication.md → docs/message.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Authentication
# Message

The Authentication component allows you to to implement authentication methods which can simply update the request
with authentication detail (for example by adding an `Authorization` header).
This is useful when you have to send multiple requests to the same endpoint. Using an authentication implementation,
these details can be separated from the actual requests.
This package contains various HTTP Message related tools:

- Authentication
- Stream encoding
- Message decorators
- [Message factory](/message-factory) for Guzzle PSR-7 and Diactoros
- Cookie


## Installation
Expand All @@ -12,8 +15,15 @@ these details can be separated from the actual requests.
$ composer require php-http/message
```

## Authentication
Copy link
Contributor

Choose a reason for hiding this comment

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

i would split the message documentation into one page per aspect: auth, stream, decorator, factory, cookie. those docs are not very closely related, and will grow over time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree: roughly equivalent to the php-http/message directory listing.


The Authentication component allows you to to implement authentication methods which can simply update the request
with authentication detail (for example by adding an `Authorization` header).
This is useful when you have to send multiple requests to the same endpoint. Using an authentication implementation,
these details can be separated from the actual requests.


## Authentication methods
### Authentication methods

Method | Parameters | Behavior
---------------- | ------------------------------------------------- | --------
Expand All @@ -28,15 +38,15 @@ Matching | An authentication instance and a matcher callback | Behavior
[2]: http://www.xml.com/pub/a/2003/12/17/dive.html


## Integration with HTTPlug
### Integration with HTTPlug

Normally requests must be authenticated "by hand" which is not really convenient.

If you use HTTPlug, you can integrate this component into the client using the
[authentication plugin](/httplug/plugins/authentication).


## Examples
### Examples

General usage looks like the following:

Expand All @@ -48,7 +58,7 @@ $authentication->authenticate($request);
```


### Basic Auth
#### Basic Auth

``` php
use Http\Message\Authentication\BasicAuth;
Expand All @@ -57,7 +67,7 @@ $authentication = new BasicAuth('username', 'password');
```


### Bearer
#### Bearer

``` php
use Http\Message\Authentication\Bearer;
Expand All @@ -66,7 +76,7 @@ $authentication = new Bearer('token');
```


### WSSE
#### WSSE

``` php
use Http\Message\Authentication\Wsse;
Expand All @@ -75,7 +85,7 @@ $authentication = new Wsse('username', 'password');
```


### Query Params
#### Query Params

`http://api.example.com/endpoint?access_token=9zh987g86fg87gh978hg9g79`

Expand All @@ -94,7 +104,7 @@ $authentication = new QueryParams([



### Chain
#### Chain

The idea behind this authentication method is that in some cases you might need to
authenticate the request with multiple methods.
Expand All @@ -115,7 +125,7 @@ $authentication = new Chain($authenticationChain);
```


### Matching
#### Matching

With this authentication method you can conditionally add authentication details to your request by passing a callable
to it. When a request is passed, the callable is called and used as a boolean value in order to decide whether
Expand Down Expand Up @@ -152,7 +162,7 @@ $authentication = Matching::createUrlMatcher(new AuthenticationMethod(), '\/api'
```


## Implement your own
### Implement your own

Implementing an authentication method is easy: only one method needs to be implemented.

Expand Down