Skip to content

Commit

Permalink
improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
janatjak committed May 11, 2017
1 parent dbb3868 commit 335ddba
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
@@ -1,4 +1,6 @@
.gitattributes export-ignore
.gitignore export-ignore
/.travis.yml export-ignore
/tests export-ignore
/.coveralls.yml export-ignore
/tests export-ignore
/docs export-ignore
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -23,5 +23,4 @@ extensions:
Documentation
-------------

// TODO
Don't use plugin cache with plugin decoder !!!
[EN](https://github.com/FreezyBee/Httplug/blob/master/docs/en/index.md)
98 changes: 98 additions & 0 deletions docs/en/index.md
@@ -0,0 +1,98 @@
Documentation
=============

More info you can see in:

- [Doc HTTPlug](http://docs.php-http.org/en/latest/httplug/introduction.html)
- [Doc HTTPlug Bundle](http://docs.php-http.org/en/latest/integrations/symfony-bundle.html) this extension is inspired by Httplug Bundle

Usage
-----

```php
$messageFactory = $container->getService('httplug.messageFactory');
$client = $container->getService('httplug.client.test');

$request = $messageFactory->createRequest('GET', 'https://google.com');
$response = $client->sendRequest($request);
```

Full configuration
------------------

```neon
extensions:
httplug: FreezyBee\Httplug\DI\HttplugExtension
httplug:
tracy:
debugger: false # default true (by %debugMode%)
plugins: [] # list of debug plugins
clientDefaults:
factory: @httplug.factory.guzzle6 # default factory for all clients
clients:
test:
factory: @httplug.factory.guzzle6 # optional if you set clientDefaults.factory
config:
# Options to the Guzzle 6 constructor
verify: false
timeout: 2
plugins:
authentication:
type: 'basic'
username: 'my_username'
password: 'p4ssw0rd'
authentication:
type: 'wsse'
username: 'my_username'
password: 'p4ssw0rd'
authentication:
type: 'bearer'
token: 'authentication_token_hash'
authentication:
type: 'service'
service: @my_authentication_service
cache:
pool: @cachePsr6 # optional - can use autowire PSR6 cache pool
streamFactory: @streamFactory # optional - can use discovered streamFactory
config:
defaultTtl: 1
respectCacheHeaders: true
cookie:
cookieJar: null # optional - if null, new http cookieJar is used
decoder:
useContentEncoding: true # DON'T USE WITH CACHE!!!
logger:
logger: @loggerPsr3 # optional - can use autowired PSR3
formatter: null
redirect:
preserveHeader: true
useDefaultForMultiple: true
retry:
retries: 1
# Set host name including protocol and optionally the port number, e.g. https://api.local:8000
addHost:
host: https://test.cz:443 # required
replace: false # Whether to replace the host if request already specifies it
# Append headers to the request. If the header already exists the value will be appended to the current value.
headerAppend:
headers:
'X-FOO': bar
# Set header to default value if it does not exist.
headerDefaults:
headers:
'X-FOO': bar
# Set headers to requests. If the header does not exist it wil be set, if the header already exists it will be replaced.
headerSet:
headers:
'X-FOO': bar
# Remove headers from requests.
headerRemove:
headers: ["X-FOO"]
test2:
factory: @httplug.factory.curl
test3:
```
1 change: 0 additions & 1 deletion src/DI/HttplugExtension.php
Expand Up @@ -23,7 +23,6 @@
use Nette\DI\Helpers;
use Nette\DI\ServiceDefinition;
use Nette\DI\Statement;
use Nette\Utils\Validators;

/**
* @author Jakub Janata <jakubjanata@gmail.com>
Expand Down

0 comments on commit 335ddba

Please sign in to comment.