PHPackages                             bfabio/publiccode-parser-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. bfabio/publiccode-parser-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

bfabio/publiccode-parser-php
============================

Parse and validate publiccode.yml files

v1.2.0(1mo ago)0127[2 issues](https://github.com/bfabio/publiccode-parser-php/issues)BSD-3-ClausePHPPHP ^8.0CI passing

Since Aug 21Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/bfabio/publiccode-parser-php)[ Packagist](https://packagist.org/packages/bfabio/publiccode-parser-php)[ Docs](https://github.com/bfabio/publiccode-parser-php)[ RSS](/packages/bfabio-publiccode-parser-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (13)Used By (0)

PHP publiccode.yml parser
=========================

[](#php-publiccodeyml-parser)

PHP bindings for the [publiccode-parser-go](https://github.com/italia/publiccode-parser-go) library. Parse and validate `publiccode.yml` files in your PHP projects.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require bfabio/publiccode-parser-php
```

### Supported Platforms

[](#supported-platforms)

This library supports the following platforms:

- **Linux x86-64** (AMD64) - Fully supported
- **Linux ARM64** (aarch64) - Fully supported
- **macOS Apple Silicon** (ARM64/M1/M2/M3/M4) - Fully supported

Usage
-----

[](#usage)

### Validation

[](#validation)

```
use Bfabio\PublicCodeParser\Parser;

$parser = new Parser();

if ($parser->isValid('/path/to/publiccode.yml')) {
    echo "publiccode.yml is valid!\n";
} else {
    echo "publiccode.yml is NOT valid!\n";
};
```

### Parsing

[](#parsing)

```
use Bfabio\PublicCodeParser\Parser;
use Bfabio\PublicCodeParser\Exception\ValidationException;
use Bfabio\PublicCodeParser\Exception\ParserException;

$parser = new Parser();

try {
    $publicCode = $parser->parseFile('/path/to/publiccode.yml');

    // // or parse from string
    // $yamlContent = file_get_contents('/path/to/publiccode.yml');
    // $publicCode = $parser->parse($yamlContent);

    echo "publiccode.yml file is valid!\n";

    // Access parsed data
    echo $publicCode->getName(); // Get software name
    echo $publicCode->getDescription('it'); // Get Italian description
    echo $publicCode->getDescription('en'); // Get English description
} catch (ValidationException $e) {
    echo "publiccode.yml file is NOT valid: " . $e->getMessage() . "\n";

    // Get detailed validation errors
    foreach ($e->getErrors() as $error) {
        echo "- " . $error . "\n";
    }
} catch (ParserException $e) {
    echo "publiccode.yml file is NOT valid: " . $e->getMessage() . "\n";
}
```

### Working with the PublicCode object

[](#working-with-the-publiccode-object)

```
$parser = new Parser();

$publicCode = $parser->parseFile('/path/to/publiccode.yml');

if ($publicCode instanceof PublicCodeV0) {
    $name = $publicCode->getName();
    $url = $publicCode->getUrl();
    $landingUrl = $publicCode->getLandingUrl();

    $descriptionIt = $publicCode->getDescription('it');
    $descriptionEn = $publicCode->getDescription('en');
    $allDescriptions = $publicCode->getAllDescriptions();

    $platforms = $publicCode->getPlatforms(); // ['web', 'android', 'ios', etc.]
}

/* In the future, when v1 will be released */
/*
else if ($publicCode instanceof PublicCodeV1) {
    ...
}
*/
```

### Advanced config

[](#advanced-config)

```
use Bfabio\PublicCodeParser\Parser;
use Bfabio\PublicCodeParser\ParserConfig;

// Create parser with custom config
$options = new ParserConfig();

$options->setDisableNetwork(true); // Disable remote existance checks for URLs

$parser = new Parser($options);
```

License
-------

[](#license)

Licensed under the EUPL 1.2. Please see [License File](LICENSE) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~40 days

Total

11

Last Release

52d ago

Major Versions

v0.3.0 → v1.0.02025-10-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a6d93678e43b814a63448122d7d0b32bedad46358e2fd2495433174b8bf3663?d=identicon)[bfabio](/maintainers/bfabio)

---

Top Contributors

[![bfabio](https://avatars.githubusercontent.com/u/788293?v=4)](https://github.com/bfabio "bfabio (75 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![saidatom](https://avatars.githubusercontent.com/u/2377368?v=4)](https://github.com/saidatom "saidatom (1 commits)")

---

Tags

parserpubliccode.ymlpublic-administration

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bfabio-publiccode-parser-php/health.svg)

```
[![Health](https://phpackages.com/badges/bfabio-publiccode-parser-php/health.svg)](https://phpackages.com/packages/bfabio-publiccode-parser-php)
```

###  Alternatives

[nikic/php-parser

A PHP parser written in PHP

17.4k902.6M1.8k](/packages/nikic-php-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k910.8M118](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.0k151.8M732](/packages/erusev-parsedown)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

3.0k404.0M702](/packages/league-commonmark)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
