https://github.com/package-url/packageurl-php
PHP implementation of the package url spec
https://github.com/package-url/packageurl-php
library package-url php purl
Last synced: 10 months ago
JSON representation
PHP implementation of the package url spec
- Host: GitHub
- URL: https://github.com/package-url/packageurl-php
- Owner: package-url
- License: mit
- Created: 2021-02-21T21:33:50.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-07-05T16:58:46.000Z (12 months ago)
- Last Synced: 2025-07-05T18:38:24.766Z (12 months ago)
- Topics: library, package-url, php, purl
- Language: PHP
- Homepage:
- Size: 268 KB
- Stars: 9
- Watchers: 2
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Package URL (purl) for PHP
[![shield_gh-workflow-test]][link_gh-workflow-test]
[![shield_packagist-version]][link_packagist]
[![shield_license]][license_file]
----
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.
## Install
```shell
composer require package-url/packageurl-php
```
## Usage
see also [the examples](https://github.com/package-url/packageurl-php/tree/main/examples).
```php
setNamespace('symfony')
->setVersion('6.3.8')
->setQualifiers([
PackageUrl::QUALIFIER_VCS_URL => 'git+https://github.com/symfony/console.git@v6.3.8',
]);
$purlString = $purl->toString();
// string(96) "pkg:composer/symfony/console@6.3.8?vcs_url=git%2Bhttps://github.com/symfony/console.git%40v6.3.8"
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);
$purl2 = PackageUrl::fromString($purlString);
// bool(true)
var_dump($purl == $purl2);
```
## Contributing
Feel free to open pull requests.
See the [contribution docs][contributing_file] for details.
[package url spec]: https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst
[license_file]: https://github.com/package-url/packageurl-php/blob/main/LICENSE
[contributing_file]: https://github.com/package-url/packageurl-php/blob/main/CONTRIBUTING.md
[shield_gh-workflow-test]: https://img.shields.io/github/actions/workflow/status/package-url/packageurl-php/php.yml?branch=main&?logo=GitHub&logoColor=white "build"
[shield_packagist-version]: https://img.shields.io/packagist/v/package-url/packageurl-php?logo=&logoColor=white "packagist"
[shield_license]: https://img.shields.io/github/license/package-url/packageurl-php "license"
[link_gh-workflow-test]: https://github.com/package-url/packageurl-php/actions?workflow=PHP+CI
[link_packagist]: https://packagist.org/packages/package-url/packageurl-php