Skip to content

support symfony/http-client #999

Closed

Description

@clxmstaab

working with the current set of http clients and packages, as described in the readme is a real pain and requires some advanced composer style fu to get right.

see https://twitter.com/markusstaab/status/1384451855418368000

I would love to use symfony/http-client with this api, but its not possible because of the long list of psr and/or http related additional requirements in the composer.json

I am not that experienced with all this psr/http related stuff, but had the hope that this could somehow be simplified. does the github-api really need all this dependencies?

or should symfony/http-client provide more stuff, so it can be used in combination with this package?

I am a bit lost

Activity

  1. matks commented on Apr 20, 2021

    @matks

    Hi @clxmstaab I just saw your tweet.

    I think the complexity you consider a pain comes from the usage of PSR-17 and PSR-18 which are very powerful and provide great interoperability at the cost of being harder to work with.

    does the github-api really need all this dependencies?

    The GitHub API project focuses on implementing the right calls and structures that mirror the GitHub API design, and lets you choose whatever http implementation you want (provided it complies with PSR-17 and PSR-18). So, yes, you need these dependencies because the project itself has no HTTP client 😄 . The project php-github-api can plug itself on a HTTP client though.

    I agree the first time, it's very unfriendly 😉 and can be unwelcoming.

    The CLI

    composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
    

    seems to provide all the necessary packages, is there an issue with this?

    Note: I'm just a user of this library, not a maintainer, so I hope I said nothing inaccurate

  2. clxmstaab commented on Apr 20, 2021

    @clxmstaab
    ContributorAuthor

    thx for your support.

    I think the complexity you consider a pain comes from the usage of PSR-17 and PSR-18 which are very powerful and provide great interoperability at the cost of being harder to work with.

    agree.

    its gettin even more complex, when you need to e.g. combine KnpLabs/php-github-api with e.g. https://github.com/lesstif/php-jira-rest-client and a few other http based packages.

    The CLI

    composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
    

    seems to provide all the necessary packages, is there an issue with this?

    from a end-user-perspective it would be easiest to use a single package instead of 2.
    I am updating from php-github-api 2.x for which even more packages were required (because of guzzle6).

  3. matks commented on Apr 20, 2021

    @matks

    For php-github-api v2 and Guzzle6, I found a very useful package https://github.com/php-http/guzzle6-adapter

    So the following set of constraints can be resolved

    {
        "name": "mypackage/mypackage",
        "require": {
            "knplabs/github-api": "^2.12",
            "php-http/guzzle6-adapter": "^1.1"
        }
    }
    
  4. clxmstaab commented on Apr 20, 2021

    @clxmstaab
    ContributorAuthor

    For php-github-api v2 and Guzzle6, I found a very useful package php-http/guzzle6-adapter

    So the following set of constraints can be resolved

    yep, this is what we have atm in production.

    I am in the process of combining it with https://github.com/phpro/soap-client and https://github.com/lesstif/php-jira-rest-client and https://github.com/cloudflare/cloudflare-php

    thats the point where it would be easier to have a single package, instead of all this cruft around it.
    thanks for your interesst in getting my problem solved. I will get this sorted somehow.


    my actual request was about the question whether things have to be that complex, or whether there is room for improvement to get things done more easily

  5. acrobat commented on Apr 21, 2021

    @acrobat
    Collaborator

    Because we depend on httplug/psr-18 it is possibly to use the symfony/http-client for this.

    To setup the library with the symfony http client, execute this composer req

    composer require knplabs/github-api:^3.0 symfony/http-client nyholm/psr7

    The nyholm/psr7 package is needed as per symfony docs

    When composer in done installing the package, you can use the symfony client with this library by specifying the client into our builder class

    use Github\Client;
    use Github\HttpClient\Builder;
    use Symfony\Component\HttpClient\HttplugClient;
    
    $builder = new Builder(new HttplugClient());
    $client = new Client($builder);

    But I understand the "over complex" feeling with all the psr's and the glue packages needed

  6. added a commit that references this issue on May 1, 2021
    5dbb5cb
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions