The `snyk-php-plugin` is a specialized plugin designed to extend the Snyk Command Line Interface (CLI) functionality for PHP Composer projects. Its primary role is to provide dependency metadata from `composer.json` and `composer.lock` files, enabling Snyk to identify, fix, and monitor known security vulnerabilities in PHP applications. The current stable version is 1.12.1, with recent releases indicating an active development cadence, including features like improved Composer command handling, Prettier integration, and enhanced security scanning capabilities. As a plugin, it is not intended for standalone programmatic use but integrates directly with the Snyk CLI to provide comprehensive security analysis for PHP dependencies, distinguishing it from general-purpose static analysis tools or package managers.
npm install snyk-php-pluginVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to programmatically use the `getDepsFromProject` function from the snyk-php-plugin. It simulates a basic PHP Composer project structure and then invokes the plugin's core logic to extract dependency information, printing the detected packages and their versions. While the primary use is via the Snyk CLI, this example illustrates direct interaction with the plugin's internal functions.
Upgrade your Node.js runtime to version 18 or higher. Use `nvm install 18 && nvm use 18` or similar version management tools.
For vulnerability scanning, install the Snyk CLI (`npm install -g snyk`) and run `snyk test` or `snyk monitor` in your PHP project directory.
Test your Snyk CLI setup with your specific Composer environment after updating the plugin. Ensure your Composer installation is up-to-date and accessible in the system's PATH.
Run `composer install` or `composer update` in your PHP project to generate or update the `composer.lock` file before running Snyk scans.
Upgrade your Node.js version to 18 or higher. Use `nvm install 18 && nvm use 18` or similar tools.
Ensure PHP and Composer are correctly installed and their executables are available in your system's PATH. You can test this by running `composer --version` in your terminal.
Navigate to the root directory of your PHP project where `composer.json` and `composer.lock` reside, or ensure these files exist. Run `composer install` if `composer.lock` is missing.
Verify that your `composer.lock` is up-to-date. Ensure you are scanning the correct project directory. Consider scanning with `--dev` flag if development dependencies are relevant. Check Snyk platform settings for scan exclusions.