From 335ddbabe5678023cad09f0dd838041ee5a6f350 Mon Sep 17 00:00:00 2001 From: Jakub Janata Date: Thu, 11 May 2017 14:12:16 +0200 Subject: [PATCH] improved docs --- .gitattributes | 4 +- README.md | 3 +- docs/en/index.md | 98 +++++++++++++++++++++++++++++++++++++ src/DI/HttplugExtension.php | 1 - 4 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 docs/en/index.md diff --git a/.gitattributes b/.gitattributes index c52d1e6..023e2ee 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,6 @@ .gitattributes export-ignore .gitignore export-ignore /.travis.yml export-ignore -/tests export-ignore \ No newline at end of file +/.coveralls.yml export-ignore +/tests export-ignore +/docs export-ignore diff --git a/README.md b/README.md index 95494ab..75bd02f 100644 --- a/README.md +++ b/README.md @@ -23,5 +23,4 @@ extensions: Documentation ------------- -// TODO -Don't use plugin cache with plugin decoder !!! \ No newline at end of file +[EN](https://github.com/FreezyBee/Httplug/blob/master/docs/en/index.md) diff --git a/docs/en/index.md b/docs/en/index.md new file mode 100644 index 0000000..cc7c9fb --- /dev/null +++ b/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: + +``` \ No newline at end of file diff --git a/src/DI/HttplugExtension.php b/src/DI/HttplugExtension.php index d225dfa..3650a8e 100644 --- a/src/DI/HttplugExtension.php +++ b/src/DI/HttplugExtension.php @@ -23,7 +23,6 @@ use Nette\DI\Helpers; use Nette\DI\ServiceDefinition; use Nette\DI\Statement; -use Nette\Utils\Validators; /** * @author Jakub Janata