You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-8Lines changed: 44 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,26 +41,62 @@ For information how to write applications with the services provided by this bun
41
41
42
42
### Use in Applications
43
43
44
+
#### Custom services
45
+
44
46
This bundle provides 3 services:
45
47
46
48
*`httplug.client` a service that provides the `Http\Client\HttpClient`
47
49
*`httplug.message_factory` a service that provides the `Http\Message\MessageFactory`
48
50
*`httplug.uri_factory` a service that provides the `Http\Message\UriFactory`
51
+
*`httplug.stream_factory` a service that provides the `Http\Message\StreamFactory`
49
52
50
53
These services are always an alias to another service. You can specify your own service or leave the default, which is the same name with `.default` appended. The default services in turn use the service discovery mechanism to provide the best available implementation. You can specify a class for each of the default services to use instead of discovery, as long as those classes can be instantiated without arguments.
51
54
52
55
If you need a more custom setup, define the services in your application configuration and specify your service in the `main_alias` section. For example, to add authentication headers, you could define a service that decorates the service `httplug.client.default` with a plugin that injects the authentication headers into the request and configure `httplug.main_alias.client` to the name of your service.
53
56
54
57
```yaml
55
58
httplug:
56
-
main_alias:
57
-
client: httplug.client.default
58
-
message_factory: httplug.message_factory.default
59
-
uri_factory: httplug.uri_factory.default
60
-
classes:
61
-
client: ~ # uses discovery if not specified
62
-
message_factory: ~
63
-
uri_factory: ~
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
+
factory: 'httplug.factory.guzzle5'
81
+
config:
82
+
# These options are given to Guzzle without validation.
0 commit comments