NativeManager
API reference › Foxy › Asset › NativeManager
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).
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$config protected constructor | Foxy\ | Foxy configuration. | AbstractManifestAssetManager |
$fs protected constructor | Composer\ | Filesystem used to resolve and update manifest paths. | AbstractManifestAssetManager |
$io protected constructor | Composer\ | Composer output used for progress messages. | AbstractManifestAssetManager |
$updatable protected | bool | Whether an existing frontend installation may be updated. Default: true. | AbstractManifestAssetManager |
Methods
Section titled “Methods”| Method | Description | Defined 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() protected | Handles dependencies already present in the frontend installation. | AbstractManifestAssetManager |
actionWhenComposerDependenciesAreMerged() protected | Runs after the Composer asset dependencies are merged and before the asset package is written. | AbstractManifestAssetManager |
getLockFilePath() protected | Returns the manager lock-file path under the root package directory. | AbstractManifestAssetManager |
getManagerConfig() protected | Returns the configuration scoped to this manager, so manager-* map entries resolve to its own value. | AbstractManifestAssetManager |
getManagerWorkingDirectory() protected | Returns the configured manager working directory, or null to use the process default. | AbstractManifestAssetManager |
getNodeModulesPath() protected | Returns the node_modules path under the root package directory. | AbstractManifestAssetManager |
getRootPackageDir() protected | Returns the resolved root package directory. | AbstractManifestAssetManager |
getRootPackagePath() protected | Resolves a path under the root package directory. | AbstractManifestAssetManager |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
NODE_MODULES_PATH | './node_modules' | AbstractManifestAssetManager |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”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
| Parameter | Type | Description |
|---|---|---|
$io | Composer\ | Output for the progress line. |
$config | Foxy\ | Foxy configuration. |
$fs | Composer\ | Filesystem used by the manifest handling. |
$installer | Foxy\ | Installer that populates the install directory. |
$registry | Foxy\ | Registry that answers the security audit. |
audit()
Section titled “audit() ”public function audit(bool $noDev): Foxy\Audit\AuditProcessResultRuns 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
| Parameter | Type | Description |
|---|---|---|
$noDev | bool | Whether to exclude development dependencies, which the native manager cannot do. |
Returns
Throws
Foxy\Exception\RuntimeException: iffoxy.lockis missing or malformed,$noDevistrue, the registry request fails, or the advisories document is malformed.
getAuditParser()
Section titled “getAuditParser() ”public function getAuditParser(): Foxy\Audit\AuditParserInterfaceReturns the parser for npm bulk-advisory documents.
Returns
getLockPackageName()
Section titled “getLockPackageName() ”public function getLockPackageName(): stringReturns the native manager lock-file name.
Returns
string
getName()
Section titled “getName() ”public function getName(): stringReturns the manager name used in Foxy configuration.
Returns
string
getVersionConstraint()
Section titled “getVersionConstraint() ”public function getVersionConstraint(): stringReturns the unrestricted version constraint because this manager runs in PHP.
Returns
string
isAvailable()
Section titled “isAvailable() ”public function isAvailable(): boolReturns whether foxy.lock exists; the native manager needs no executable.
Returns
bool
isInstalled()
Section titled “isInstalled() ”public function isInstalled(): boolReturns 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.
run()
Section titled “run() ”public function run(): intInstalls 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 thezlibextension is missing, the configured root package directory does not exist, the install directory is invalid, or the installation fails.
validate()
Section titled “validate() ”public function validate(): voidChecks that the zlib extension, which reads the gzip-compressed tarballs, is loaded.
Throws
Foxy\Exception\RuntimeException: if thezlibextension is missing.