PHPackages                             berlioz/doc-parser - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. berlioz/doc-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

berlioz/doc-parser
==================

Berlioz Doc Parser is a PHP library to parse documentation and allow to integrate this on website for example.

v2.1.0(2mo ago)0144MITPHPPHP ^8.0CI passing

Since Apr 27Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/BerliozFramework/DocParser)[ Packagist](https://packagist.org/packages/berlioz/doc-parser)[ Docs](https://getberlioz.com)[ RSS](/packages/berlioz-doc-parser/feed)WikiDiscussions main Synced 2mo ago

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

Berlioz Doc Parser
==================

[](#berlioz-doc-parser)

[![Latest Version](https://camo.githubusercontent.com/78c0f01e202c424984a4dd10d39afcc67888c8f0aa7034ea3898696b1251c591/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265726c696f7a2f646f632d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://github.com/BerliozFramework/DocParser/releases)[![Software license](https://camo.githubusercontent.com/a7b02e7e7114275720c6fc30e936620bf72d1d01e7e7fab2a8ae6f27607224ec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4265726c696f7a4672616d65776f726b2f446f635061727365722e7376673f7374796c653d666c61742d737175617265)](https://github.com/BerliozFramework/DocParser/blob/main/LICENSE)[![Build Status](https://camo.githubusercontent.com/12a7d07bd746530c1a6569150f80016dc3c9f2409efda403185b5a437a4f4c9b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4265726c696f7a4672616d65776f726b2f446f635061727365722f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d7465737473)](https://github.com/BerliozFramework/DocParser/actions/workflows/tests.yml?query=branch%3Amain)[![Quality Grade](https://camo.githubusercontent.com/0562aed24fd78afcc8bed3f773456f31bb5ed3e7c98a58f27ee7f0e41a7ebe9d/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f62353264346338366332303834333439383535643361643234663266386237632f6d61696e2e7376673f7374796c653d666c61742d737175617265)](https://www.codacy.com/manual/BerliozFramework/DocParser)[![Total Downloads](https://camo.githubusercontent.com/33d16f0480d3128a9b093eabded20c34f4e20ca0a465ae05938e663d147bc495/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6265726c696f7a2f646f632d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/berlioz/doc-parser)

**Berlioz Doc Parser** is a PHP library to parse documentation and allow to integrate this on website for example.

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

[](#installation)

### Composer

[](#composer)

You can install **Berlioz Doc Parser** with [Composer](https://getcomposer.org/), it's the recommended installation.

```
$ composer require berlioz/doc-parser
```

### Dependencies

[](#dependencies)

- **PHP** ^8.0
- PHP libraries:
    - **mbstring**
- Packages:
    - **berlioz/html-selector**
    - **berlioz/http-message**
    - **league/flysystem**

To parse files, you need additional package:

- For MarkDown files: `league/commonmark`
- For reStructuredText files: `gregwar/rst`

Usage
-----

[](#usage)

Library use `league/flysystem` library to manipulate files. This library permit to use some adapter like **Local files**, **GitLab**, **Google**... that's very useful for documentation source.

### Documentation generation

[](#documentation-generation)

You need to define the parser of you documentation, in the example: `Berlioz\DocParser\Parser\Markdown`.

```
use Berlioz\DocParser\DocGenerator;
use Berlioz\DocParser\Parser\Markdown;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;

$version = '1.0';

$docGenerator = new DocGenerator();
$docGenerator->addParser(new Markdown());
$documentation =
    $docGenerator->handle(
        $version,
        new Filesystem(new LocalFilesystemAdapter('/path-of-project/doc'))
    );
```

### Documentation files

[](#documentation-files)

You can access to documentation files easily:

```
/** @var \Berlioz\DocParser\Doc\Documentation $documentation */
$files = $documentation->getFiles();
```

And filter the files by type:

```
use Berlioz\DocParser\Doc\File\FileInterface;
use Berlioz\DocParser\Doc\File\Page;

/** @var \Berlioz\DocParser\Doc\Documentation $documentation */
$pages = $documentation->getFiles(fn(FileInterface $file) => $file instanceof Page);
```

Two file type exists:

- `Berlioz\DocParser\Doc\File\Page`: page with parsed content
- `Berlioz\DocParser\Doc\File\RawFile`: raw file like images

### Documentation handle

[](#documentation-handle)

When your documentation is generate, you can use `Documentation::handle()` method to get pages and files.

```
use Berlioz\DocParser\Doc\Documentation;
use Berlioz\DocParser\Doc\File\Page;

/** @var Documentation $documentation */
$file = $documentation->handle('path/of/my/page');

if (null === $file) {
   // Show not found error
}

// Raw file?
if (!$file instanceof Page) {
    // Return \Psr\Http\Message\ResponseInterface object
    return $file->response();
}

// Show HTML content of my page
echo $file->getContents();
```

### Treatments

[](#treatments)

A concept of treatment is implement to manipulate files after generation.

Some treatments are activate by default:

- `Berlioz\DocParser\Treatment\DocSummaryTreatment`: generate the summary of documentation
- `Berlioz\DocParser\Treatment\PageSummaryTreatment`: generate the pages summaries
- `Berlioz\DocParser\Treatment\PathTreatment`: resolve all links to transform in relative links
- `Berlioz\DocParser\Treatment\TitleTreatment`: extract title of page and set to `Page` object

Optionals treatments are available:

- `Berlioz\DocParser\Treatment\BootstrapTreatment`: add CSS classes to HTML elements to beautify them for Bootstrap framework

You can also create your treatment class and add this to generator:

```
use Berlioz\DocParser\DocGenerator;
use Berlioz\DocParser\Treatment\BootstrapTreatment;

/** @var DocGenerator $docGenerator */
$docGenerator->addTreatment(new BootstrapTreatment($docGenerator));
```

### Formats

[](#formats)

#### MarkDown

[](#markdown)

A specific tag is for indexation of documentation.

```
```index
title: Title of page
slug: Slug name (replace only the filename, not path)
breadcrumb: Category; Sub category; My page
summary-order: 1
summary-visible: true
```

```

#### reStructuredText

[](#restructuredtext)

A specific directive is for indexation of documentation.

```
...index:
    :title: Title of page
    :slug: Slug name (replace only the filename, not path)
    :breadcrumb: Category; Sub category; My page
    :summary-order: 1
    :summary-visible: true

```

#### Options available for indexation

[](#options-available-for-indexation)

- `title`: replace the title of page, the title treatment does not replace this title
- `slug`: replace the filename of page, not the complete path, it's an url encoded representation of value
- `breadcrumb`: the breadcrumb of page into the documentation summary, if not present, the page will not in the summary
- `summary-order`: the order in summary section
- `summary-visible`: default to true, but you can define the page to not visible in summary

You can define your own options, for your treatments for example, options are available with `Page::getMeta(...)` method.

### Summary

[](#summary)

#### Doc summary

[](#doc-summary)

Doc summary references all pages with a breadcrumb. It's a hierarchy of `Berlioz\DocParser\Doc\Summary\Entry` objects.

You can get path of entry with method `Entry::getPath()`, it's the absolute path from root directory of documentation.

#### Page summary

[](#page-summary)

Page summary references all headings in the page content. It's a hierarchy of `Berlioz\DocParser\Doc\Summary\Entry` objects.

No path given to the entry, but an id `Entry::getId()` linked to the corresponding heading.

### Parser

[](#parser)

Two parser are available by default:

- `Berlioz\DocParser\Parser\Markdown`: to parse MarkDown files, use `league/commonmark` package
- `Berlioz\DocParser\Parser\reStructuredText`: to parse reStructuredText files, use `gregwar/rst` package

You can also create your own parser, you need only to implement `Berlioz\DocParser\Parser\ParserInterface` interface.

If you need to add an extension to a specific parser, a getter method is available to access to the original parser. Example for MarkDown parser: `\Berlioz\DocParser\Parser\Markdown::getCommonMarkConverter()`.

You can also pass to the `Markdown` and `reStructuredText` constructors the same parameters that corresponding libraries.

### Cache

[](#cache)

Generation of documentation take time, and it's not acceptable to generate documentation at every request.

`Berlioz\DocParser\DocCacheGenerator` class generate a cache of generated and treated documentation to reuse it quickly. The cache use `league/flysystem` package to store cache files.

Example of usage:

```
use Berlioz\DocParser\DocCacheGenerator;
use Berlioz\DocParser\DocGenerator;
use Berlioz\DocParser\Parser\Markdown;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;

$version = '1.0';
$cacheFilesystem = new Filesystem(new LocalFilesystemAdapter('/path-of-project/cache'));
$docCacheGenerator = new DocCacheGenerator($cacheFilesystem);

if (null === ($documentation = $docCacheGenerator->get($version))) {
    $docGenerator = new DocGenerator();
    $docGenerator->addParser(new Markdown());
    $documentation =
        $docGenerator->handle(
            $version,
            new Filesystem(new LocalFilesystemAdapter('/path-of-project/doc'))
        );

    $docCacheGenerator->save($documentation);
}

$documentation->handle('path/of/my/page');
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance83

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~163 days

Recently: every ~407 days

Total

14

Last Release

87d ago

Major Versions

v0.2-alpha → v1.0.02020-12-01

v1.3.0 → v2.0.0-beta12021-09-03

PHP version history (3 changes)v0.1-alphaPHP ^7.1

v0.2-alphaPHP ^7.4 || ^8.0

v2.0.0-beta1PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18268216?v=4)[Ronan Giron](/maintainers/ElGigi)[@ElGigi](https://github.com/ElGigi)

---

Top Contributors

[![ElGigi](https://avatars.githubusercontent.com/u/18268216?v=4)](https://github.com/ElGigi "ElGigi (87 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/berlioz-doc-parser/health.svg)

```
[![Health](https://phpackages.com/badges/berlioz-doc-parser/health.svg)](https://phpackages.com/packages/berlioz-doc-parser)
```

###  Alternatives

[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4723.6M20](/packages/coenjacobs-mozart)[afosto/yaac

Yet Another ACME client: a decoupled LetsEncrypt client

245500.4k1](/packages/afosto-yaac)[ckfinder/ckfinder-laravel-package

CKFinder 3 package for Laravel

159497.2k48](/packages/ckfinder-ckfinder-laravel-package)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[ckfinder/ckfinder-symfony-bundle

CKFinder bundle for Symfony

42435.7k](/packages/ckfinder-ckfinder-symfony-bundle)[setono/sylius-feed-plugin

Plugin to generate feeds within the Sylius ecommerce platform

26458.2k](/packages/setono-sylius-feed-plugin)

PHPackages © 2026

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