Skip to content

Commit

Permalink
Doc tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Jul 24, 2013
1 parent d800878 commit 6468795
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,13 @@ Simply extending Request and Response may pose some problems:
different subsystems of your application.
2. The `Request::createFromPHPRequest` factory always returns a instance of
`Request` so you would have to override the factory method as well.
3. By controlling the instantation of specific `Request` and `Response`
instances in your library or application, you make it harder to work with
other applications who also use `sabre/http`.
3. By controlling the instantation and depend on specific `Request` and
`Response` instances in your library or application, you make it harder to
work with other applications which also use `sabre/http`.

In short: it would be bad design. Instead, it's recommended to use the
[decorator pattern][6] to add new behavior in the specific application or
subsystems where you need them. sabre/http provides helper classes to quickly
do this.
[decorator pattern][6] to add new behavior where you need it. sabre/http
provides helper classes to quickly do this.

Example:

Expand Down Expand Up @@ -179,11 +178,14 @@ This package also contains a simple wrapper around [cURL][4], which will allow
you to write simple clients, using the `Request` and `Response` objects you're
already familiar with.

It's by no means a replacement for something like [guzzle][7], but it provides
a simple and lightweight api for making the occasional API call.

### Usage

```php
use Sabre\HTTP;

include 'vendor/autoload.php';

$request = new HTTP\Request('GET', 'http://example.org/');
$request->setHeader('X-Foo', 'Bar');

Expand Down Expand Up @@ -234,7 +236,6 @@ $client->on('error:401', function($request, $response, &$retry, $retryCount) {
});
```


The Request and Response API's
------------------------------

Expand Down Expand Up @@ -651,3 +652,4 @@ function getHttpVersion();
[4]: http://uk3.php.net/curl
[5]: https://github.com/fruux/sabre-event
[6]: http://en.wikipedia.org/wiki/Decorator_pattern
[7]: http://guzzlephp.org/

0 comments on commit 6468795

Please sign in to comment.