Skip to content
PHP Ecosystem
Explore

NativeInstaller

API reference › Foxy › Native › NativeInstaller

final readonly classFoxy\Native\NativeInstaller
ImplementsNativeInstallerInterface
Sourcesrc/Native/NativeInstaller.php

Installs the frontend dependencies of a package.json into a flat directory (node_modules by default) without a Node.js package manager.

Registry packages are resolved (or read from a fresh foxy.lock), downloaded, and extracted into <install directory>/.foxy-tmp before being moved into place; file: packages are copied from their local directory. Top-level entries of the install directory outside the install set are removed, except dot-entries such as .bin. A registry package already in place with its recorded lock entry is kept; see InstalledState.

MethodDescriptionDefined by
__construct()Creates the native package installer.NativeInstaller
install()Installs the dependencies declared by the manifest, reading or rewriting the lock file.NativeInstaller
public function __construct(Composer\IO\IOInterface $io, Composer\Util\Filesystem $fs, Foxy\Native\NpmRegistryInterface $registry, Foxy\Native\DependencyResolver $resolver, Foxy\Native\TarballExtractor $extractor)

Creates the native package installer.

Parameters

ParameterTypeDescription
$ioComposer\IO\IOInterfaceOutput that receives one line per changed package, and per kept package at verbose level.
$fsComposer\Util\FilesystemFilesystem used to copy, move, and remove package directories.
$registryNpmRegistryInterfaceRegistry that provides the tarballs.
$resolverDependencyResolverResolver of the registry requirements.
$extractorTarballExtractorExtractor of the downloaded tarballs.
public function install(string $manifestPath, string $lockPath, string $installDirectory, bool $update): void

Installs the dependencies declared by the manifest, reading or rewriting the lock file.

A missing manifest declares no dependency. An optional file: package whose package.json is missing is skipped with a warning. The dependencies, devDependencies, and optionalDependencies maps are merged, an optional entry overriding a mandatory one of the same name as npm does; an unsatisfiable optional entry is skipped with a warning. The lock file is reused when it is fresh (same requirements, same local package versions) and $update is false; otherwise the requirements are resolved again and the lock file is written before any package is installed, so a download failure leaves a usable lock file.

Parameters

ParameterTypeDescription
$manifestPathstringPath of the root package.json.
$lockPathstringPath of the foxy.lock file.
$installDirectorystringPath of the directory to populate (node_modules by default).
$updateboolWhether to resolve again even when the lock file is fresh.

Throws

  • Foxy\Exception\RuntimeException: if a manifest is invalid, a mandatory local package is missing, a local package overlaps the install directory, a requirement cannot be resolved or downloaded, the lock file is malformed, a local package cannot be copied, or an existing package directory cannot be removed.