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
+37-8
Original file line number
Diff line number
Diff line change
@@ -43,19 +43,26 @@ For information how to write applications with the services provided by this bun
43
43
44
44
#### Custom services
45
45
46
-
This bundle provides 3 services:
47
46
48
-
*`httplug.client` a service that provides the `Http\Client\HttpClient`
49
-
*`httplug.message_factory` a service that provides the `Http\Message\MessageFactory`
50
-
*`httplug.uri_factory` a service that provides the `Http\Message\UriFactory`
51
-
*`httplug.stream_factory` a service that provides the `Http\Message\StreamFactory`
47
+
| Service id | Description |
48
+
| ---------- | ----------- |
49
+
| httplug.message_factory | Service* that provides the `Http\Message\MessageFactory`
50
+
| httplug.uri_factory | Service* that provides the `Http\Message\UriFactory`
51
+
| httplug.stream_factory | Service* that provides the `Http\Message\StreamFactory`
52
+
| httplug.client.[name] | This is your Httpclient that you have configured. With the configuration below the name would be `acme_client`.
53
+
| httplug.client | This is the first client configured or a client named `default`.
54
+
| httplug.plugin.content_length <br> httplug.plugin.decoder<br> httplug.plugin.error<br> httplug.plugin.logger<br> httplug.plugin.redirect<br> httplug.plugin.retry | These are build in plugins that lives in the `php-http/plugins` package. These servcies are not public and may only be used when configure HttpClients or services.
52
55
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.
56
+
\**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.*
54
57
55
58
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.
56
59
57
60
```yaml
58
61
httplug:
62
+
clients:
63
+
acme_client: # This is the name of the client
64
+
factory: 'httplug.factory.guzzle6'
65
+
59
66
main_alias:
60
67
client: httplug.client.default
61
68
message_factory: httplug.message_factory.default
@@ -80,16 +87,16 @@ httplug:
80
87
factory: 'httplug.factory.guzzle5'
81
88
config:
82
89
# These options are given to Guzzle without validation.
Rather than code against specific HTTP clients, you want to use the Httplug `Client` interface. To avoid building your own infrastructure to define services for the client, simply `require: php-http/httplug-bundle` in your bundles `composer.json`. You SHOULD provide configuration for each of your services that needs an HTTP client to specify the service to use, defaulting to `httplug.client`. This way, the default case needs no additional configuration for your users.
0 commit comments