Skip to content

Commit e930743

Browse files
committed
Added doc about clients
1 parent cad78a5 commit e930743

File tree

1 file changed

+37
-17
lines changed

1 file changed

+37
-17
lines changed

README.md

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,47 @@ If you need a more custom setup, define the services in your application configu
5656

5757
```yaml
5858
httplug:
59-
main_alias:
60-
client: httplug.client.default
61-
message_factory: httplug.message_factory.default
62-
uri_factory: httplug.uri_factory.default
63-
stream_factory: httplug.stream_factory.default
64-
classes:
65-
# uses discovery if not specified
66-
client: ~
67-
message_factory: ~
68-
uri_factory: ~
69-
stream_factory: ~
70-
clients:
71-
acme:
72-
adapter: guzzle5
73-
config:
74-
timeout: 2
75-
verify: false
59+
main_alias:
60+
client: httplug.client.default
61+
message_factory: httplug.message_factory.default
62+
uri_factory: httplug.uri_factory.default
63+
stream_factory: httplug.stream_factory.default
64+
classes:
65+
# uses discovery if not specified
66+
client: ~
67+
message_factory: ~
68+
uri_factory: ~
69+
stream_factory: ~
70+
```
71+
72+
#### Configure your client
73+
74+
You can configure your clients with some good default options. The clients are later registered as services.
75+
76+
```yaml
77+
httplug:
78+
clients:
79+
my_guzzle5:
80+
adapter: guzzle5
81+
config:
82+
# These options are given to Guzzle without validation.
83+
base_url: 'http://google.se/'
84+
defaults:
85+
verify_ssl: false
86+
timeout: 4
87+
headers:
88+
Content-Type: 'application/json'
89+
acme:
90+
adapter: guzzle6
91+
config:
92+
# These options are given to Guzzle without validation.
93+
base_url: 'http://google.se/'
94+
7695
```
7796

7897
```php
7998

99+
$httpClient = $this->container->get('httplug.my_guzzle5');
80100
$httpClient = $this->container->get('httplug.acme');
81101
```
82102

0 commit comments

Comments
 (0)