Skip to content

Skip auto-installing when the root package's extra.discovery is enough #237

Description

@nicolas-grekas

Here is an idea that popped up in #236 and that builds on #232.

When the root package configures this:

    "extra": {
        "discovery": {
            "psr/http-factory-implementation": "My\\Psr17Factory"
        }
    }

then we shouldn't need auto-installing any extra packages for this virtual package.

Same when listing individual interfaces:

    "extra": {
        "discovery": {
            "Psr\\Http\\Client\\ClientInterface": "My\\Psr18Client"
        }
    }

In this case, we should verify that all the interfaces required to fulfill one of the supported *-implementation are listed.

Activity

  1. dbu commented on Apr 28, 2023

    @dbu
    Contributor

    thanks for the discussion in #236 . a workaround for now would be to do the composer config allow-plugins.php-http/discovery false from the readme, correct? and have the internal package provide the required *-implemenation information for composer.

    I agree we can't check just for the *-implementation of installed packages because that still does not tell which classes to use. and scanning the code for implementing interfaces is too fragile (and a performance problem when no caching mechanism is available). while afaik java does support this sort of self-registration and autodiscovery mechanisms, i agree with not going that far.

    the change suggested here would be that the existing configuration to chose which class to use for which psr factory also accepts unknown classes in addition to the well-known ones, right? that seems consistent with what we have and non-surprising.
    (btw there is some doc that is only in the readme but missing from https://docs.php-http.org/en/latest/discovery.html, we should sync the 2 places when we do this change)

  2. nicolas-grekas commented on Apr 28, 2023

    @nicolas-grekas
    CollaboratorAuthor

    composer config allow-plugins.php-http/discovery false

    correct!

    the existing configuration to chose which class to use for which psr factory also accepts unknown classes in addition to the well-known ones

    This works already!
    The only thing missing is skipping the installation of well-know packages when all interfaces of the virtual package are listed.

  3. dbu commented on Apr 28, 2023

    @dbu
    Contributor

    oh even better. yeah then its not much left to be done 👍

    and i just realized that you just added the pinning recently. neat, thanks!

  4. nicolas-grekas commented on May 3, 2023

    @nicolas-grekas
    CollaboratorAuthor

    Implemented in #239

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions