Skip to content

Bundle config reference #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/img/symfony-profiler/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/symfony-profiler/request-stack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions integrations/symfony-bundle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,44 @@ Web Debug Toolbar

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the logging is also controlled by a config setting that defaults to kernel.debug, right? we could maybe mention that below, near where we talk about the body capturing configuration


You can configure the bundle to show debug information for clients found with discovery. You may also force a specific client to be found when a third party library is using discovery. The configuration below makes sure the client with service id ``httplug.clients.my_guzzle5`` is returned when calling ``HttpClientDiscovery::find()`` . It does also make sure to show debug info for asynchronous clients.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would move the topic of auto discovery to the end of the debug toolbar section, with a heading one level below web debug toolbar, to make it more clear this is about an edge case. and i would mention in the intro of this subsection that explicit DI is preferred.


.. code-block:: yaml

httplug:
clients:
my_guzzle5:
factory: 'httplug.factory.guzzle5'
discovery:
client: 'httplug.clients.my_guzzle5'
async_client: 'auto'

The debug info for normal HTTP clients are enabled by default but not for async clients. You can turn all debug info off for auto discovered clients by setting the value to ``false``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets try to make this more readable:

For normal clients, the auto discovery debug info is enabled by default. For async clients, debug is not enabled by default to avoid errors when using the bundle with a client that can not do async. To get debug information for async clients, set discovery.async_client to 'auto' or an explicit client.

You can turn off all interaction of the bundle with auto discovery by setting the value of discovery.client to false.


The web profiler page will show you lots of information about the request and also how different plugins changes the message. See example screen shots below.

.. image:: /assets/img/symfony-profiler/dashboard.png
:width: 200px
:align: left

.. image:: /assets/img/symfony-profiler/request-stack.png
:width: 200px
:align: left

.. image:: /assets/img/symfony-profiler/error-plugin-failure.png
:width: 200px
:align: left

|clearfloat|

The body of the HTTP messages is not captured by default because of performance reasons. Turn this on by changing the ``captured_body_length`` configuration.

.. code-block:: yaml

httplug:
toolbar:
captured_body_length: 1000 # Capture the first 1000 chars of the HTTP body

Discovery of Factory Classes
````````````````````````````

Expand Down Expand Up @@ -157,6 +195,23 @@ You can configure a client with authentication. Valid authentication types are `
factory: 'httplug.factory.guzzle6'
plugins: ['httplug.plugin.authentication.my_wsse']

Special HTTP clients
````````````````````

If you want to use the ``FlexibleHttpClient`` or ``HttpMethodsClient`` from the ``php-http/message`` package you may specify that on the client configuration.

.. code-block:: yaml

// config.yml
httplug:
clients:
acme:
factory: 'httplug.factory.guzzle6'
flexible_client: true

foobar:
factory: 'httplug.factory.guzzle6'
http_methods_client: true

List of Services
````````````````
Expand Down Expand Up @@ -198,3 +253,7 @@ Usage for Reusable Bundles
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 a configuration option to specify the which HTTP client service to use for each of your services. This option should default to ``httplug.client``. This way, the default case needs no additional configuration for your users, but they have the option of using specific clients with each of your services.

The only steps they need is ``require`` one of the adapter implementations in their projects ``composer.json`` and instantiating the ``HttplugBundle`` in their kernel.

.. |clearfloat| raw:: html

<div style="clear:left"></div>
14 changes: 13 additions & 1 deletion integrations/symfony-full-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,24 @@ This page shows an example of all configuration values provided by the bundle.
stopwatch:
enabled: true
stopwatch: 'debug.stopwatch'

toolbar:
enabled: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be kernel.debug, no? or is it only ever asked for if the debug toolbar itself is enabled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be kernel.debug, no?

No. kernel.debug=false will turn off the toolbar.
kernel.debug=true allows you to control the toolbar with toolbar.enabled

or is it only ever asked for if the debug toolbar itself is enabled?

correct

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, then its fine like this

formatter: null # Defaults to \Http\Message\Formatter\FullHttpMessageFormatter
captured_body_length: 0

discovery:
client: 'auto'
async_client: false

clients:
acme:
factory: 'httplug.factory.guzzle6'
plugins: ['httplug.plugin.authentication.my_wsse', 'httplug.plugin.cache', 'httplug.plugin.retry']
flexible_client: false
http_methods_client: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment that only one of the two can be true for a specific client?

config:
verify: false
timeout: 2
# more options to the guzzle 6 constructor
# more options to the Guzzle 6 constructor

1 change: 1 addition & 0 deletions spelling_word_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ username
whitelist
wiki
workflow
profiler