diff --git a/docs/cookbook/httplug-bundle.md b/docs/cookbook/httplug-bundle.md new file mode 100644 index 00000000..70e5c626 --- /dev/null +++ b/docs/cookbook/httplug-bundle.md @@ -0,0 +1,42 @@ +# HTTPlug bundle + +If you are using [Symfony](http://symfony.com/) +with the [HTTPlug bundle](http://docs.php-http.org/en/latest/integrations/symfony-bundle.html), +you may want to setup the client to take benefit of the profiling, without have to re-configure all the stuff. + +To do it, we have to call `Docker\DockerClient::createFormEnv` factory method from the HTTPlug factory. + +First, declare the factory service: + +```yaml +services: + httplug.factory.docker: + class: Http\HttplugBundle\Collector\ProfileClientFactory + arguments: + $factory: [ Docker\DockerClient, 'createFromEnv' ] +``` + +The `ProfileClientFactory` will detect and call the passed `DockerClient` factory method. + +Then, declare the client on the HTTPlug bundle configuration: + +```yaml +httplug: + plugins: + logger: ~ + clients: + docker: + factory: 'httplug.factory.docker' + plugins: ['httplug.plugin.logger'] +``` + +Finally, declare your `Docker\Docker` instance as a service, giving the HTTPlug client wrapper: + +```yaml +services: + Docker\Docker: + arguments: + $httpClient: '@httplug.client.docker' +``` + +And voilĂ ! Just call your `Docker\Docker` service and you will get the same result with profiling and logs. diff --git a/docs/index.md b/docs/index.md index 79390ca3..50a89d3a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -20,3 +20,4 @@ problems and advanced usage when using Docker-PHP * [Running a container](cookbook/container-run.md) * [Build an image](cookbook/build-image.md) +* [HTTPlug Bundle](cookbook/httplug-bundle.md)