Skip to content

Instantly share code, notes, and snippets.

@bartfeenstra
Last active July 6, 2016 15:03
Show Gist options
  • Save bartfeenstra/9ebfcb1b5fc80e536ecfba0d19d96a20 to your computer and use it in GitHub Desktop.
Save bartfeenstra/9ebfcb1b5fc80e536ecfba0d19d96a20 to your computer and use it in GitHub Desktop.

In a built application, we want the application to check whether an arbitrary package has been built (composer install) into the code base.

We were originally thinking of storing a list of all installed packages (including their replace links) and that works for our test cases, but I can image it won't work for chained replacements, for instance: the requirements for package A are checked. A depends on D. The application already has B installed, which replaces C, which replaced D. As such, D is available within the system and A can be installed, but our code currently does not correctly output this, as it only stores B's replaced packages, which is C. It doesn't store C's replaced packages (D). We also need to perform this check programmatically, so there is no CLI environment. The reason we need this, is that the application allows extensions to be enabled runtime (so after the code base has been built), but it must make sure the code base has indeed been built correctly. Those extensions are also their own Composer packages, and may be available for discovery in the application without having been installed through Composer.

Alternatively we are considering just checking whether the package-to-be-installed is present in the list of installed packages, which simplifies the check, but still has the potential of causing false negatives if the package in question is available, but only because it is replaced by a package that is in turn also replaced by another package that is actually installed (see the aforementioned example with packages A, B, and C).

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