PHPackages                             rayne/wz2008-graph - 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. rayne/wz2008-graph

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

rayne/wz2008-graph
==================

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

1.1.6(4y ago)173MITPHPPHP &gt;=5.6

Since Feb 5Pushed 4y ago2 watchersCompare

[ Source](https://github.com/Rayne/wz2008-graph)[ Packagist](https://packagist.org/packages/rayne/wz2008-graph)[ RSS](/packages/rayne-wz2008-graph/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (7)Dependencies (3)Versions (14)Used By (0)

Rayne/wz2008-graph
==================

[](#raynewz2008-graph)

`Rayne/wz2008-graph` parses the "Classification of Economic Activities" issued by the Statistisches Bundesamt. It builds multiple hierarchically structured and object oriented in-memory trees from flat file structures with implicit hierarchy.

[![Latest Stable Version](https://camo.githubusercontent.com/5745599736f2613062ef20d4b45b087285901e1a6fdcd00fd90e3b42746b56b5/68747470733a2f2f706f7365722e707567782e6f72672f7261796e652f777a323030382d67726170682f762f737461626c65)](https://packagist.org/packages/rayne/wz2008-graph)[![Latest Unstable Version](https://camo.githubusercontent.com/7710da65971e63203e12668267f73b8de67546e50b0ed8357c9acc8714242d80/68747470733a2f2f706f7365722e707567782e6f72672f7261796e652f777a323030382d67726170682f762f756e737461626c65)](https://packagist.org/packages/rayne/wz2008-graph)[![Build Status](https://camo.githubusercontent.com/a3e2b042acb77fea45ed3889d9f6535641f8edae22b9797a1ce9268ff4290115/68747470733a2f2f7472617669732d63692e6f72672f5261796e652f777a323030382d67726170682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Rayne/wz2008-graph)[![Code Coverage](https://camo.githubusercontent.com/d5023a6c2daa945208a54c4aa1b43c19e1c6804070e157968fbf35a69c476c42/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7261796e652f777a323030382d67726170682f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rayne/wz2008-graph/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/92822486f1b4809af209b2d319cc70cb1c682d44475d10b584988af9b067bf6c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7261796e652f777a323030382d67726170682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rayne/wz2008-graph/?branch=master)[![License](https://camo.githubusercontent.com/d35f33144083c94d48523e3e8c10d9b9358f1d1427956fe15ef5eb813b40f518/68747470733a2f2f706f7365722e707567782e6f72672f7261796e652f777a323030382d67726170682f6c6963656e7365)](https://packagist.org/packages/rayne/wz2008-graph)

[![Rayne/wz2008-graph builds a tree structure](./assets/cover-image.png "Rayne/wz2008-graph builds a tree structure")](./assets/cover-image.png)

Contents
--------

[](#contents)

- [Paketbeschreibung](#paketbeschreibung-german)
- [Dependencies](#dependencies)
    - [Production](#production)
    - [Development](#development)
- [Licence](#licence)
- [Setup](#setup)
- [Benchmarks](#benchmarks)
- [Tests](#tests)
- [Usage](#usage)
    - [Search WzItem by ID](#search-wzitem-by-id)
    - [Traverse WzItems](#traverse-wzitems)
    - [Traverse Parents](#traverse-parents)
    - [Traverse Children](#traverse-children)
    - [Filter WzItems by Level](#filter-wzitems-by-level)
    - [Get translated Labels](#get-translated-labels)
    - [Get WzItem ID](#get-wzitem-id)
    - [Get WzItem Level](#get-wzitem-level)
- [Custom Data Sets](#custom-data-sets)

Paketbeschreibung (German)
--------------------------

[](#paketbeschreibung-german)

Diese Bibliothek extrahiert die implizit vorliegende hierarchische Branchen-Struktur aus der *Klassifikation der Wirtschaftszweige, Ausgabe 2008 (WZ 2008)*. Als Daten-Grundlage wird die vollständige Klassifikation als XML-Datei genutzt.

> Die Klassifikation der Wirtschaftszweige, Ausgabe 2008 (WZ 2008), wurde unter intensiver Beteiligung von Datennutzern und Datenproduzenten in Verwaltung, Wirtschaft, Forschung und Gesellschaft geschaffen und dient dazu, die wirtschaftlichen Tätigkeiten von Unternehmen, Betrieben und anderen statistischen Einheiten in allen amtlichen Statistiken einheitlich zu erfassen. Sie berücksichtigt die Vorgaben der statistischen Systematik der Wirtschaftszweige in der Europäischen Gemeinschaft (NACE Rev. 2), die mit der Verordnung (EG) Nr. 1893/2006 des Europäischen Parlaments und des Rates vom 20. Dezember 2006 (ABl. EG Nr. L 393 S. 1) veröffentlicht wurde und auf der International Standard Industrial Classification (ISIC Rev. 4) der Vereinten Nationen basiert. Die Zustimmung der Europäischen Kommission gemäß Artikel 4, Absatz 3, der oben genannten Verordnung liegt vor.
>
> Die Anwendung der WZ 2008 für statistische Zwecke ergibt sich aus Artikel 8 der oben genannten Verordnung. Danach sind Statistiken, die sich auf vom 1. Januar 2008 an durchgeführte Wirtschaftstätigkeiten beziehen (Berichtsperiode), auf der Grundlage der NACE Rev. 2 (in Deutschland auf der Grundlage der WZ 2008) zu erstellen. Abweichend hiervon sind Konjunkturstatistiken gemäß der Verordnung (EG) Nr. 1165/98 und der Arbeitskostenindex gemäß der Verordnung (EG) Nr. 450/2003 ab dem 1. Januar 2009 auf Basis der NACE Rev. 2 (in Deutschland auf Basis der WZ 2008) zu erstellen. Die Anwendung ab 2008/2009 gilt nicht für folgende Statistiken: Statistiken der Volkswirtschaftlichen Gesamtrechnungen gemäß der Verordnung (EG) Nr. 2223/96, die Landwirtschaftliche Gesamtrechnung gemäß der Verordnung (EG) Nr. 138/2004 und Statistiken der Zahlungsbilanz, des internationalen Dienstleistungsverkehrs und der Direktinvestitionen gemäß der Verordnung (EG) Nr. 184/2005. Diese Statistiken wenden die NACE Rev. 2 / WZ 2008 ab einem späteren Zeitpunkt an.
>
> Quelle:

Dependencies
------------

[](#dependencies)

### Production

[](#production)

- PHP 5.6 or better

### Development

[](#development)

- Composer
- Git
- PHPUnit

Licence
-------

[](#licence)

- The library is published under the [MIT licence](LICENSE).
- The shipped `/assets/WZ2008-[…].xml` file is intellectual property of the *Statistisches Bundesamt (Federal Statistical Office), Wiesbaden, Section „Classifications“*.

    ```
    File content: Classification (complete)
    Further information: https://www.klassifikationsserver.de/
    Copyright: © Statistisches Bundesamt, Wiesbaden 2008 Distribution (also in parts) permitted, provided that the source is mentioned.
    Owner: Issued by: Statistisches Bundesamt (Federal Statistical Office), Wiesbaden, Section „Classifications“, Phone.: 0611/75-2510, -2294, -2280, Fax: 0611/75-3953,  E-Mail: wz@destatis.de
    Type: 'ex' = Part of (see help of the classification server)

    ```

Setup
-----

[](#setup)

[Download Composer](https://getcomposer.org/download) and install `rayne/wz2008-graph`.

```
composer require rayne/wz2008-graph
```

*Alternatives*

- Clone the repository (see the [Tests](#tests) chapter)
- Download a [zipped release](https://github.com/Rayne/wz2008-graph/releases)

Benchmarks
----------

[](#benchmarks)

It is recommended to call the `phpbench` program directly instead of using the provided `composer bench` script. The latter will kill the benchmark after five minutes.

```
./vendor/bin/phpbench run
```

Tests
-----

[](#tests)

1. Clone the repository

    ```
    git clone https://github.com/rayne/wz2008-graph.git
    ```
2. Install the development dependencies

    ```
    composer install --dev --prefer-dist
    ```
3. Run the tests

    ```
    composer test
    ```

Usage
-----

[](#usage)

```
use Rayne\wz2008\Graph\Factory\WzClassificationFactory;
use Rayne\wz2008\Graph\WzClassificationInterface;

/**
 * @var WzClassificationInterface $classification
 */

// Load the library's classification file …
$classification = WzClassificationFactory::build();

// … or load a custom classification file.
$classification = WzClassificationFactory::buildFromFile(
    'WZ2008-2016-07-29-Classification_(complete).xml');
```

### Search WzItem by ID

[](#search-wzitem-by-id)

```
use Rayne\wz2008\Graph\WzClassificationInterface;
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzClassificationInterface $classification
 * @var WzItemInterface $item
 */

$id = '26.20.0';

if ($classification->has($id)) {
    $item = $classification->get($id);
}
```

### Traverse WzItems

[](#traverse-wzitems)

It's possible to traverse parents and children relative to a given `WzItemInterface` object. Every item has a hierarchy level between `1` and `5`. `WzItemInterface` provides the following human readable constants.

DEENLevelConstantAbschnittSection1`WzItemInterface::LEVEL_SECTION`AbteilungDivision2`WzItemInterface::LEVEL_DIVISION`GruppeGroup3`WzItemInterface::LEVEL_GROUP`KlasseClass4`WzItemInterface::LEVEL_CLASS`UnterklasseSubclass5`WzItemInterface::LEVEL_SUBCLASS`#### Traverse Parents

[](#traverse-parents)

Fetch the direct parent or traverse one level up.

```
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var WzItemInterface|null $parent
 */

$parent = $item->getParent();
```

Fetch the parent on a specific level or move up to a specific level.

```
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var WzItemInterface|null $parent
 */

$parent = $item->getParentByLevel($item::LEVEL_SECTION);
```

#### Traverse Children

[](#traverse-children)

Fetch all direct children.

```
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var WzItemInterface[] $children
 */

$children = $item->getChildren();
```

Fetch all children by a specific level. Children on other levels are skipped.

```
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var WzItemInterface[] $children
 */

$children = $item->getChildrenByLevel($item::LEVEL_CLASS);
```

Filter WzItems by Level
-----------------------

[](#filter-wzitems-by-level)

Get all `WzItemInterface` items with a specific level.

```
use Rayne\wz2008\Graph\WzClassificationInterface;
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzClassificationInterface $classification
 * @var WzItemInterface[] $sections
 */

$sections = $classification->getItemsByLevel(WzItemInterface::LEVEL_SECTION);
```

Get translated Labels
---------------------

[](#get-translated-labels)

`WzItemInterface` throws an `InvalidArgumentException`when there isn't a translation for the given language code. The official XML files are limited to `DE` and `EN`.

The `$langCode` of `WzItemInterface->getLabel($langCode)` is case-insensitive.

```
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var string $label
 */

$label = $item->getLabel('de');
```

Get all translated labels and their language codes.

```
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var string[] $labels
 */

$labels = $item->getLabels();
```

`WzItemInterface->getLabels()` returns simple key (language code) value (translated label) maps.

```
$labels = [
    'de' => 'Wirtschafts- und Arbeitgeberverbände',
    'en' => 'Activities of business and employers membership organisations',
];
```

### Get WzItem ID

[](#get-wzitem-id)

```
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 */

$item->getId();
```

### Get WzItem Level

[](#get-wzitem-level)

```
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 */

$item->getLevel();
```

Custom Data Sets
----------------

[](#custom-data-sets)

1. Download a `WZ2008-20XX-XX-XX-Classification_(complete).xml` file

    1. Visit [klassifikationsserver.de/klassService/index.jsp?variant=wz2008](https://klassifikationsserver.de/klassService/index.jsp?variant=wz2008)
    2. Locate the `ZIP` download in the download matrix at position

        ```
        ("Klassifikation komplett", "XML (Claset)")

        ```
    3. Extract the downloaded `ZIP` file
2. Use the factory to build a `WzClassificationInterface` object based upon the downloaded XML file

    ```
    use Rayne\wz2008\Graph\Factory\WzClassificationFactory;
    use Rayne\wz2008\Graph\WzClassificationInterface;

    /**
    * @var WzClassificationInterface $classification
    */

    $classification = WzClassificationFactory::buildFromFile(
        'WZ2008-2016-07-29-Classification_(complete).xml');
    ```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

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 ~255 days

Total

11

Last Release

1802d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c8280f00784624f044fa15aa869fd0a3958b0ade356a01297eff1f6240332e2?d=identicon)[Rayne](/maintainers/Rayne)

---

Top Contributors

[![Rayne](https://avatars.githubusercontent.com/u/1098733?v=4)](https://github.com/Rayne "Rayne (32 commits)")

---

Tags

isicnaicsstatistisches-bundesamtwirtschaftszweigewz2008treegraphwz2008wirtschaftszweigenacenaicsisicstatistisches-bundesamt

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/rayne-wz2008-graph/health.svg)

```
[![Health](https://phpackages.com/badges/rayne-wz2008-graph/health.svg)](https://phpackages.com/packages/rayne-wz2008-graph)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M41](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[moonshine/layouts-field

Field for repeating groups of fields for MoonShine

107.9k](/packages/moonshine-layouts-field)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

112.9k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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