PHP code example of gumslone / laravel-package-url
1. Go to this page and download the library: Download gumslone/laravel-package-url library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Purl;
Purl::isValid('pkg:npm/[email protected]'); // true
Purl::parse('pkg:npm/[email protected]'); // PackageUrl
Purl::parseMany([...]); // Collection<PackageUrl>, invalid skipped
// Find every purl embedded in a block of text (SBOM, manifest, log, changelog)
Purl::extractAll($text); // Collection<PackageUrl>, de-duplicated
// Type
Purl::isType('pkg:cargo/[email protected]', 'cargo'); // true
Purl::isGeneric('pkg:generic/[email protected]'); // true
// Can this purl produce a URL?
Purl::hasRepositoryUrl('pkg:composer/laravel/[email protected]'); // true
Purl::hasDownloadUrl('pkg:npm/[email protected]'); // true
Purl::hasDownloadUrl('pkg:npm/left-pad'); // false (no version)
Purl::hasRegistryApiUrl('pkg:cargo/[email protected]'); // true
Purl::isConvertibleToUrl('pkg:npm/left-pad'); // true (any of the above)
// Can this URL be turned into a purl?
Purl::isConvertibleDownloadUrl('https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz'); // true
Purl::isConvertibleUrl('[email protected]:laravel/framework.git'); // true (also accepts repo/SSH URLs)