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
+87-74
Original file line number
Diff line number
Diff line change
@@ -1,74 +1,60 @@
1
1
Symfony Bundle
2
2
==============
3
3
4
-
The usage documentation is split into two parts. First we explain how to configure the bundle in an application. The second part is for developing reusable Symfony bundles that depend on an HTTP client defined by the Httplug interface.
4
+
This bundle integrate HTTPlug with the Symfony framework. The bundle helps to register services for all your clients and makes sure all the configuration is in one place. The bundle also feature a toolbar plugin with information about your requests.
5
5
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.*
25
+
Installation
26
+
````````````
44
27
28
+
Install the Httplug bundle with composer and enabled it in your AppKernel.php.
45
29
46
-
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
+
.. code-block:: bash
47
31
48
-
.. code-block:: yaml
32
+
$ composer require php-http/httplug-bundle
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
+
.. code-block:: php
35
+
36
+
public function registerBundles()
37
+
{
38
+
$bundles = array(
39
+
// ...
40
+
new Http\HttplugBundle\HttplugBundle(),
41
+
);
42
+
}
66
43
44
+
You will find all available configuration at the :doc:`full configuration </integrations/symfony-full-configuration>` page.
67
45
68
-
Configuration without auto discovery
69
-
````````````````````````````````````
46
+
Web debug toolbar
47
+
`````````````````
48
+
.. image:: assets/img/debug-toolbar.png
49
+
:align:right
50
+
:width:120px
70
51
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):
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.
53
+
54
+
Discovery of factory classes
55
+
````````````````````````````
56
+
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,64 +96,90 @@ 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.
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