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: integrations/symfony-bundle.rst
+83-70Lines changed: 83 additions & 70 deletions
Original file line number
Diff line number
Diff line change
@@ -5,70 +5,56 @@ The usage documentation is split into two parts. First we explain how to configu
5
5
6
6
For information how to write applications with the services provided by this bundle, have a look at the [Httplug documentation](http://docs.php-http.org).
\* *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.*
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.
30
+
Install the Httplug Bundle with composer and enabled it in your AppKernel.php.
47
31
48
-
.. code-block:: yaml
32
+
.. code-block:: bash
49
33
50
-
httplug:
51
-
clients:
52
-
acme_client: # This is the name of the client
53
-
factory: 'httplug.factory.guzzle6'
54
-
55
-
main_alias:
56
-
client: httplug.client.default
57
-
message_factory: httplug.message_factory.default
58
-
uri_factory: httplug.uri_factory.default
59
-
stream_factory: httplug.stream_factory.default
60
-
classes:
61
-
# uses discovery if not specified
62
-
client: ~
63
-
message_factory: ~
64
-
uri_factory: ~
65
-
stream_factory: ~
34
+
$ composer require php-http/httplug-bundle
35
+
36
+
.. code-block:: php
37
+
38
+
public function registerBundles()
39
+
{
40
+
$bundles = array(
41
+
// ...
42
+
new Http\HttplugBundle\HttplugBundle(),
43
+
);
44
+
}
45
+
46
+
Web debug toolbar
47
+
`````````````````
48
+
.. image:: assets/img/debug-bar.png
49
+
:align:right
50
+
:width:120px
66
51
52
+
When using a client configured with HttplugBundle you will get debug information in the web debug toolbar. It will tell you how many request were made and how many of those that were successful or not. It will also show you detailed information about each request.
67
53
68
-
Configuration without auto discovery
69
-
````````````````````````````````````
54
+
Discovery of factory classes
55
+
````````````````````````````
70
56
71
-
By default we use Puli to auto discover factories. If you do not want to use auto discovery you could use the following configuration (Guzzle):
57
+
If you want to automatically find our factory classes you should install and enabled ``puli/symfony-bundle``. If you do not want use auto discovery you should specify all the factory classes for you client. The following example show how you configure factory classes using Guzzle.
72
58
73
59
.. code-block:: yaml
74
60
@@ -80,10 +66,11 @@ By default we use Puli to auto discover factories. If you do not want to use aut
You can configure your clients with some good default options. The clients are later registered as services.
73
+
You can configure your clients with default options. These default values will be specific to you client you are using. The clients are later registered as services.
87
74
88
75
.. code-block:: yaml
89
76
@@ -109,18 +96,21 @@ You can configure your clients with some good default options. The clients are l
You can configure the clients with plugins. You can choose to use a built in plugin in the ``php-http/plugins`` package or provide a plugin of your own. The order of the specified plugin does matter.
117
107
118
108
.. code-block:: yaml
119
109
120
110
// services.yml
121
111
acme_plugin:
122
-
class: Acme\Plugin\MyCustonPlugin
123
-
arguments: ["%api_key%"]
112
+
class: Acme\Plugin\MyCustomPlugin
113
+
arguments: ["%some_parameter%"]
124
114
125
115
.. code-block:: yaml
126
116
@@ -132,41 +122,64 @@ You can configure the clients with plugins.
You can configure a client with authentication. Valid authentication types are ``basic``, ``bearer``, ``service`` and ``wsse``. See more examples at the :doc:`full configuration </integrations/symfony-full-configuration>`.
\* *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.*
0 commit comments