Skip to content

Commit d02d918

Browse files
committed
Added table with services
1 parent e0b6643 commit d02d918

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,26 @@ For information how to write applications with the services provided by this bun
4343

4444
#### Custom services
4545

46-
This bundle provides 3 services:
4746

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.
5255

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.*
5457

5558
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.
5659

5760
```yaml
5861
httplug:
62+
clients:
63+
acme_client: # This is the name of the client
64+
factory: 'httplug.factory.guzzle6'
65+
5966
main_alias:
6067
client: httplug.client.default
6168
message_factory: httplug.message_factory.default
@@ -105,21 +112,22 @@ You can configure the clients with plugins.
105112

106113
```yaml
107114
// services.yml
108-
my_cache_plugin:
109-
class: Http\Client\Plugin\CachePlugin
110-
arguments: ["@cache", "@stream_factory"]
115+
acme_plugin:
116+
class: Acme\Plugin\MyCustonPlugin
117+
arguments: ["%api_key%"]
111118
```
112119
```yaml
113120
// config.yml
114121
httpug:
115122
clients:
116123
acme:
117124
factory: 'httplug.factory.guzzle6'
118-
plugins: ['my_cache_plugin' , 'httplug.plugin.logger']
125+
plugins: ['acme_plugin' , 'httplug.plugin.logger']
119126
config:
120127
base_uri: 'http://google.se/'
121128
```
122129
130+
123131
### Use for Reusable Bundles
124132
125133
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

Comments
 (0)