Skip to content
PHP Ecosystem
Explore

NativeManager

API reference › Foxy › Asset › NativeManager

final classFoxy\Asset\NativeManager
ExtendsAbstractManifestAssetManager
ImplementsAssetManagerInterface
Sourcesrc/Asset/NativeManager.php

Provides the native asset manager: installs package.json dependencies from the npm registry in PHP, recording them in foxy.lock, without a Node.js package manager.

Never selected automatically unless foxy.lock exists; manager: native selects it explicitly. Packages are installed into the native-install-dir directory (node_modules by default).

PropertyTypeDescriptionDefined by
$config protected constructorFoxy\Config\ConfigFoxy configuration.AbstractManifestAssetManager
$fs protected constructorComposer\Util\FilesystemFilesystem used to resolve and update manifest paths.AbstractManifestAssetManager
$io protected constructorComposer\IO\IOInterfaceComposer output used for progress messages.AbstractManifestAssetManager
$updatable protectedboolWhether an existing frontend installation may be updated. Default: true.AbstractManifestAssetManager
MethodDescriptionDefined by
__construct()Creates the native manager with its installer and npm registry client.NativeManager
addDependencies()Merges Composer asset dependencies into the frontend package manifest.AbstractManifestAssetManager
audit()Runs the security audit of the locked registry packages with one request to the registry’s bulk advisories endpoint.NativeManager
getAuditParser()Returns the parser for npm bulk-advisory documents.NativeManager
getLockPackageName()Returns the native manager lock-file name.NativeManager
getName()Returns the manager name used in Foxy configuration.NativeManager
getPackageJsonPath()Returns the frontend package manifest path.AbstractManifestAssetManager
getPackageName()Returns the frontend package manifest filename.AbstractManifestAssetManager
getVersionConstraint()Returns the unrestricted version constraint because this manager runs in PHP.NativeManager
hasLockFile()Returns whether the manager lock file exists.AbstractManifestAssetManager
isAvailable()Returns whether foxy.lock exists; the native manager needs no executable.NativeManager
isInstalled()Returns whether the install directory and package.json exist.NativeManager
isUpdatable()Returns whether an existing frontend installation may be updated.AbstractManifestAssetManager
run()Installs the dependencies, or updates them when updates are allowed by setUpdatable(), as composer update does, even if nothing is installed yet.NativeManager
setUpdatable()Enables or disables updates of an existing frontend installation.AbstractManifestAssetManager
validate()Checks that the zlib extension, which reads the gzip-compressed tarballs, is loaded.NativeManager
actionWhenComposerDependenciesAreAlreadyInstalled() protectedHandles dependencies already present in the frontend installation.AbstractManifestAssetManager
actionWhenComposerDependenciesAreMerged() protectedRuns after the Composer asset dependencies are merged and before the asset package is written.AbstractManifestAssetManager
getLockFilePath() protectedReturns the manager lock-file path under the root package directory.AbstractManifestAssetManager
getManagerConfig() protectedReturns the configuration scoped to this manager, so manager-* map entries resolve to its own value.AbstractManifestAssetManager
getManagerWorkingDirectory() protectedReturns the configured manager working directory, or null to use the process default.AbstractManifestAssetManager
getNodeModulesPath() protectedReturns the node_modules path under the root package directory.AbstractManifestAssetManager
getRootPackageDir() protectedReturns the resolved root package directory.AbstractManifestAssetManager
getRootPackagePath() protectedResolves a path under the root package directory.AbstractManifestAssetManager
ConstantValueDescriptionDefined by
NODE_MODULES_PATH'./node_modules'AbstractManifestAssetManager
public function __construct(Composer\IO\IOInterface $io, Foxy\Config\Config $config, Composer\Util\Filesystem $fs, Foxy\Native\NativeInstallerInterface $installer, Foxy\Native\NpmRegistryInterface $registry)

Creates the native manager with its installer and npm registry client.

Parameters

ParameterTypeDescription
$ioComposer\IO\IOInterfaceOutput for the progress line.
$configFoxy\Config\ConfigFoxy configuration.
$fsComposer\Util\FilesystemFilesystem used by the manifest handling.
$installerFoxy\Native\NativeInstallerInterfaceInstaller that populates the install directory.
$registryFoxy\Native\NpmRegistryInterfaceRegistry that answers the security audit.
public function audit(bool $noDev): Foxy\Audit\AuditProcessResult

Runs the security audit of the locked registry packages with one request to the registry’s bulk advisories endpoint.

Local file: packages are skipped, and a lock without registry packages is clean without a request. The exit code is 1 when the document reports an advisory and 0 otherwise; the error output is always empty.

Parameters

ParameterTypeDescription
$noDevboolWhether to exclude development dependencies, which the native manager cannot do.

Returns

Foxy\Audit\AuditProcessResult

Throws

  • Foxy\Exception\RuntimeException: if foxy.lock is missing or malformed, $noDev is true, the registry request fails, or the advisories document is malformed.
public function getAuditParser(): Foxy\Audit\AuditParserInterface

Returns the parser for npm bulk-advisory documents.

public function getLockPackageName(): string

Returns the native manager lock-file name.

Returns

string

public function getName(): string

Returns the manager name used in Foxy configuration.

Returns

string

public function getVersionConstraint(): string

Returns the unrestricted version constraint because this manager runs in PHP.

Returns

string

public function isAvailable(): bool

Returns whether foxy.lock exists; the native manager needs no executable.

Returns

bool

public function isInstalled(): bool

Returns whether the install directory and package.json exist.

Returns

bool

Throws

  • Foxy\Exception\RuntimeException: if the configured install directory is the root package directory, one of its parents, or a filesystem root, or if a symbolic link in it or in the root package directory cannot be resolved.
public function run(): int

Installs the dependencies, or updates them when updates are allowed by setUpdatable(), as composer update does, even if nothing is installed yet.

Returns 0 without doing anything when run-asset-manager is disabled. An installer exception propagates unchanged.

Returns

int

Throws

  • Foxy\Exception\RuntimeException: if the zlib extension is missing, the configured root package directory does not exist, the install directory is invalid, or the installation fails.
public function validate(): void

Checks that the zlib extension, which reads the gzip-compressed tarballs, is loaded.

Throws