Skip to content

Repository files navigation

Package URL (purl) for PHP

shield_gh-workflow-testshield_packagist-versionshield_license


A parser and builder based on package url spec, implemented in PHP.

License: MIT

Note

PackageURL (PURL) is currently undergoing a process of review and standardization, leading to updates in the specification.
As a result, this library may no longer comply with the latest PURL standards. It will not receive further updates until the standardization process is complete and a stable version of the specification is released. See #243

Install

composer require package-url/packageurl-php

Usage

see also the examples.

<?phpusePackageUrl\PackageUrl;
$purl = (newPackageUrl('composer', 'console'))
->setNamespace('symfony')
->setVersion('6.3.8')
->setQualifiers([
PackageUrl::QUALIFIER_VCS_URL => 'git+https://github.com/symfony/console.git@v6.3.8',
]);
$purlString = $purl->toString();
var_dump($purlString);
// string(96) "pkg:composer/symfony/console@6.3.8?vcs_url=git%2Bhttps://github.com/symfony/console.git%40v6.3.8"var_dump((string) $purl);
// string(96) "pkg:composer/symfony/console@6.3.8?vcs_url=git%2Bhttps://github.com/symfony/console.git%40v6.3.8"$purl2 = PackageUrl::fromString($purlString);
var_dump($purl == $purl2);
// bool(true)

Contributing

Feel free to open pull requests.
See the contribution docs for details.

About

PHP implementation of the package url spec

Topics

Resources

Contributing

Security policy

Stars

13 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages