Skip to content

Symfony bridge #255

Closed as not planned
Closed as not planned

Description

@soullivaneuh

It would be a great addition to propose a Symfony integration bridge as a bundle.

Would you accept it here? I could work on it.

Otherwise, I'll create an external bundle.

Activity

  1. joelwurtz commented on Oct 20, 2017

    @joelwurtz
    Member

    Sorry for late answer, goal is to provide here a symfony integration by using the PluginClientFactory from php-http

  2. soullivaneuh commented on Oct 22, 2017

    @soullivaneuh
    ContributorAuthor

    Yes. But I think we should require php-http/httplug-bundle in this case, and some adjustment might be done to make it easier.

    I currently have an implementation. but it's quite tricky:

    services:
      httplug.factory.docker:
        class: AppBundle\Httplug\ClientFactory\CallableClientFactory
        arguments:
          $factory: [ Docker\DockerClient, 'createFromEnv' ]
      Docker\Docker:
        arguments:
          $httpClient: '@httplug.client.docker'
    

    Config:

    httplug:
      plugins:
        logger: ~
      clients:
        default:
          factory: 'httplug.factory.guzzle6'
          plugins: ['httplug.plugin.logger']
        docker:
          factory: 'httplug.factory.docker'
          plugins: ['httplug.plugin.logger']
      profiling:
        captured_body_length: 1000
    

    See also php-http/HttplugBundle#210.

  3. joelwurtz commented on Oct 22, 2017

    @joelwurtz
    Member

    Would prefer to have a suggest for the bundle with the integration directly in this lib, so not required to use docker-php but suggested when using in cujunction with symfony

  4. soullivaneuh commented on Oct 22, 2017

    @soullivaneuh
    ContributorAuthor

    @joelwurtz It would obviously be a suggestion as this library is not a bundle.

    It's the concept of a bridge. ;-)

    Example: https://github.com/Soullivaneuh/IsoCodesValidator/tree/fc143a075c2b379dd1bf6147d2848071cabccff8/src/Bridge

  5. joelwurtz commented on Oct 22, 2017

    @joelwurtz
    Member

    cac4840

    I believe this is enough for the next version of httplug bundle

  6. soullivaneuh commented on Oct 22, 2017

    @soullivaneuh
    ContributorAuthor

    Maybe, have to try. 😉

  7. soullivaneuh commented on Oct 23, 2017

    @soullivaneuh
    ContributorAuthor

    @joelwurtz I don't really see how this commit will make things simpler, could you please elaborate?

    At the end, I still have to call DockerClient::createFromEnv manually or on the services, but how can I manage it from the bundle configuration? Assuming this:

    httplug:
      plugins:
        logger: ~
      clients:
        default:
          factory: 'httplug.factory.guzzle6'
          plugins: ['httplug.plugin.logger']
      profiling:
        captured_body_length: 1000
    

    How can I manage to add, for example, the logger plugin?

    AFAIK, the logic should be reversed and the socket client be called as a service from here. This is why I was talking about a bridge.

    A I wrong?

  8. soullivaneuh commented on Oct 23, 2017

    @soullivaneuh
    ContributorAuthor

    I finish to end up with this:

    services:
      Docker\DockerClient:
        factory: [ Docker\DockerClient, 'createFromEnv', [ '@httplug.factory.socket' ] ]
      Docker\Docker:
        factory: [ Docker\Docker, 'create', [ '@Docker\DockerClient' ] ]

    And I indeed got a profiling and logging.

    Is it what you was thinking about?

  9. soullivaneuh commented on Oct 23, 2017

    @soullivaneuh
    ContributorAuthor

    Another weird thing: The Docker\Docker::create method takes the version as first argument. But the previous service configuration works... plus, I tried to pass a specific version to test:

      Docker\Docker:
        factory: [ Docker\Docker, 'create', [ !php/const:Docker\Docker::VERSION_1_31, '@Docker\DockerClient' ] ]

    But the version is stuck at 1.32.

  10. soullivaneuh commented on Oct 23, 2017

    @soullivaneuh
    ContributorAuthor

    Ok so just forgot the two past comments, the configuration was wrong.

    Fun facts: If i do:

    services:
      Docker\DockerClient:
        factory: [ Docker\DockerClient, 'createFromEnv', [ '@httplug.factory.socket' ] ]
      Docker\Docker:
        factory: [ Docker\Docker, 'create' ]
        arguments:
          $version: !php/const:Docker\Docker::VERSION_1_32
          $httpClient: '@Docker\DockerClient'

    It works, but with 0 log.

    If I remove the built http-client:

    services:
      Docker\Docker:
        factory: [ Docker\Docker, 'create' ]
        arguments:
          $version: !php/const:Docker\Docker::VERSION_1_32

    I got this exception:

    19:09:23 ERROR     [app] Error: "cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)" when emitting request: "POST /v1.32/containers/create 1.1" ["request" => GuzzleHttp\Psr7\Request { …},"exception" => Http\Client\Exception\RequestException { …}] []
    19:09:23 ERROR     [app] Http\Client\Exception\RequestException exception thrown during analysis #17. ["message" => "cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)","code" => 0,"file" => "/code/vendor/php-http/guzzle6-adapter/src/Promise.php","line" => 135] []
    

    It's seems the library factory got a curl client.

    I have no more ideas at the moment. I'll wait an answer before trying to do anything else on this library. 😉

  11. soullivaneuh commented on Oct 23, 2017

    @soullivaneuh
    ContributorAuthor

    Well, last thing, this is even worst. I rolled back to my current config:

    httplug:
      plugins:
        logger: ~
      clients:
        default:
          factory: 'httplug.factory.guzzle6'
          plugins: ['httplug.plugin.logger']
        docker:
          factory: 'httplug.factory.docker'
          plugins: ['httplug.plugin.logger']
      profiling:
        captured_body_length: 1000
    
    services:
      httplug.factory.docker:
        class: AppBundle\Httplug\ClientFactory\CallableClientFactory
        arguments:
          $factory: [ Docker\DockerClient, 'createFromEnv' ]
      Docker\Docker:
        factory: [ Docker\Docker, 'create' ]
        arguments:
          $version: !php/const:Docker\Docker::VERSION_1_32
          $httpClient: '@httplug.client.docker'

    And this is not working anymore:

    19:18:41 ERROR     [app] TypeError exception thrown during analysis #17. ["message" => "Argument 1 passed to Docker\DockerClient::createFromEnv() must be an instance of Http\Client\Common\PluginClientFactory or null, array given, called in /code/src/AppBundle/Httplug/ClientFactory/CallableClientFactory.php on line 34","code" => 0,"file" => "/code/vendor/docker-php/docker-php/src/DockerClient.php","line" => 64] []
    
  12. joelwurtz commented on Oct 24, 2017

    @joelwurtz
    Member

    Will try to see what the fucks happens, but i believe this :

    services:
      Docker\DockerClient:
        factory: [ Docker\DockerClient, 'createFromEnv', [ '@httplug.factory.socket' ] ]
      Docker\Docker:
        factory: [ Docker\Docker, 'create', [ '@Docker\DockerClient' ] ]
    

    is the correct solution

  13. joelwurtz commented on Oct 24, 2017

    @joelwurtz
    Member

    ping @fbourigault maybe he have some input on this

  14. fbourigault commented on Oct 24, 2017

    @fbourigault

    As Docker\DockerClient have to support the unix:// scheme, the only Http\Client\HttpClient you can use is the SocketClient. So, you can either not rely on HttplugBundle and provide customization options with this library or allow any Http\Client\HttpClient implementation and let it fail if scheme is unix:// and client not a SocketClient.

  15. soullivaneuh commented on Oct 25, 2017

    @soullivaneuh
    ContributorAuthor

    As Docker\DockerClient have to support the unix:// scheme, the only Http\Client\HttpClient you can use is the SocketClient

    I quite agree. But have to notice that if somebody create another client supporting unix://, it will not able to be added. Am I right? But maybe not a big deal. Here, we have some customization that are currently not used at all.

    @joelwurtz This solution looks nice. php-http/HttplugBundle#210 (comment)

    Would you let me give a try on a PR?

  16. joelwurtz commented on Oct 26, 2017

    @joelwurtz
    Member

    Would you let me give a try on a PR?

    Yes go ahead

    As i'm not using docker with symfony ATM as long as it play nice and looks correct i will gladly merge this.

  17. soullivaneuh commented on Oct 26, 2017

    @soullivaneuh
    ContributorAuthor

    Good to hear that, I'll give a try while working on my project, thanks.

  18. Rid commented on Oct 8, 2026

    @Rid
    Member

    Closing as part of triage for the 3.x release.

    3.x accepts any PSR-18 client in Docker::create(), so a client configured as a Symfony service can be passed in directly. We don't plan to ship a Symfony bundle in this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions