Methods |
public
static
|
getInstalledPackages(): string[]
Returns a list of all package names which are present, either by being installed, replaced or provided
Returns a list of all package names which are present, either by being installed, replaced or provided
|
#
|
public
static
|
getInstalledPackagesByType(string $type): string[]
Returns a list of all package names with a specific type e.g. 'library'
Returns a list of all package names with a specific type e.g. 'library'
|
#
|
public
static
|
isInstalled(string $packageName, bool $includeDevRequirements = true): bool
Checks whether the given package is installed
Checks whether the given package is installed
This also returns true if the package name is provided or replaced by another package
|
#
|
public
static
|
satisfies(VersionParser $parser, string $packageName, string|null $constraint): bool
Checks whether the given package satisfies a version constraint
Checks whether the given package satisfies a version constraint
e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
Parameters
$parser |
Install composer/semver to have access to this class and functionality
|
$constraint |
A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
|
#
|
public
static
|
getVersionRanges(string $packageName): string
Returns a version constraint representing all the range(s) which are installed for a given package
Returns a version constraint representing all the range(s) which are installed for a given package
It is easier to use this via isInstalled() with the $constraint argument if you need to check
whether a given version of a package is installed, and not just whether it exists
Returns
Version constraint usable with composer/semver
|
#
|
public
static
|
getVersion(string $packageName): string|null
Returns
If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
#
|
public
static
|
getPrettyVersion(string $packageName): string|null
Returns
If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
#
|
public
static
|
getReference(string $packageName): string|null
Returns
If the package is being replaced or provided but is not really installed, null will be returned as reference
|
#
|
public
static
|
getInstallPath(string $packageName): string|null
Returns
If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
#
|
public
static
|
getRootPackage(): array
|
#
|
public
static
|
getRawData(): array[]
Returns the raw installed.php data for custom implementations
Returns the raw installed.php data for custom implementations
Deprecated
Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
#
|
public
static
|
getAllRawData(): array[]
Returns the raw data of all installed.php which are currently loaded for custom implementations
Returns the raw data of all installed.php which are currently loaded for custom implementations
|
#
|
public
static
|
reload(
array{root: array{name: string, pretty_version: string, version: string, reference: (string|null), type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: (string|null), type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data,
): void
Lets you reload the static array from another file
Lets you reload the static array from another file
This is only useful for complex integrations in which a project needs to use
this class but then also needs to execute another project's autoloader in process,
and wants to ensure both projects have access to their version of installed.php.
A typical case would be PHPUnit, where it would need to make sure it reads all
the data it needs from this class, then call reload() with
require $CWD/vendor/composer/installed.php (or similar) as input to make sure
the project in which it runs can then also use this class safely, without
interference between PHPUnit's dependencies and the project's dependencies.
|
#
|