PHPackages                             kolyunya/wiki-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. kolyunya/wiki-parser

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

kolyunya/wiki-parser
====================

MediaWiki categories parser

26PHP

Since Feb 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Kolyunya/wiki-parser)[ Packagist](https://packagist.org/packages/kolyunya/wiki-parser)[ RSS](/packages/kolyunya-wiki-parser/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Wiktionary parser
=================

[](#wiktionary-parser)

Description
-----------

[](#description)

This parser parses [MediaWiki](https://www.mediawiki.org) categories.

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

[](#installation)

This package is [composer-enabled](https://packagist.org/packages/kolyunya/wiki-parser). Just require it in your `composer.json`.

```
"require": {
    "kolyunya/wiki-parser": "*"
}
```

Usage example
-------------

[](#usage-example)

The following code parses [English nouns](https://en.wiktionary.org/wiki/Category:English_nouns) to a file.

```
// Create a parser instance.
$parser = new Parser();

// Set host to wiktionary
$host = new Wiktionary();
$parser->setHost($host);

// Set language to English.
$language = new EnglishLanguage();
$parser->setLanguage($language);

// Set category to nouns.
$category = new NounsCategory();
$parser->setCategory($category);

// Add a filter which will filter out all non-alphabetical words.
$filter = new AlphabetFilter();
$parser->addFilter($filter);

// Create a processor which will write all words to a file.
$processor = new FileSaver();
$parser->addProcessor($processor);

// Perform parsing.
$parser->parse();
```

Available filters
-----------------

[](#available-filters)

- `WordFilter` - passes words matching the `^\w+$` regular expression pattern.
- `AlphabetFilter` - passes words containing only alphabetical characters in a corresponding language.
- `MinimumLengthFilter` - passes words longer than a specified length.
- `MaximumLengthFilter` - passes words shorter than a specified length.

Available processors
--------------------

[](#available-processors)

- `StdoutPrinter` - prints all words to the `stdout`.
- `FileSaver` - saves all words to a specified file.
- `DatabaseSaver` - saves all words to a database.
- `LowercaseShifter` - converts all words to a lowercase.
- `UppercaseShifter` - converts all words to an uppercase.

Adding languages
----------------

[](#adding-languages)

To add an arbitrary language you should implement the `LanguageInterface`. It contains only to methods. The `getCode` method must return the standard language code (e.g. `en` for English). The `getAlphabet` method must return an array of letters in language alphabet.

Custom categories
-----------------

[](#custom-categories)

The recomended way of implementing custom categories is to extend the `BaseCategory` class. You should use the `setTitle` method in your category class constructor to add titles for specific languages.

```
class NounsCategory extends BaseCategory implements CategoryInterface
{
    public function __construct()
    {
        $this->setTitle(new EnglishLanguage(), 'Category:English_nouns');
        $this->setTitle(new FrenchLanguage(), 'Catégorie:Noms_communs_en_français');
        $this->setTitle(new GermanLanguage(), 'Kategorie:Substantiv_(Deutsch)');
        $this->setTitle(new RussianLanguage(), 'Категория:Русские_существительные');
    }
}
```

Custom processors
-----------------

[](#custom-processors)

If you need to implement a custom processor you have two options.

First, you can implement the `ProcessorInterface` which is quite straightforward.

```
class StdoutPrinter implements ProcessorInterface
{
    public function process(LanguageInterface $language, &$item)
    {
        $data = "$item\n";
        echo $data;
    }
}
```

Second, you can use a `CustomProcessor` which should be provided with a callback function which will do something.

```
$stdoutPrinter = new CustomProcessor(
    function (LanguageInterface $language, &$item) {
        $data = "$item\n";
        echo $data;
    }
);
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2682768?v=4)[Nick Oleynikov](/maintainers/Kolyunya)[@Kolyunya](https://github.com/Kolyunya)

---

Top Contributors

[![Kolyunya](https://avatars.githubusercontent.com/u/2682768?v=4)](https://github.com/Kolyunya "Kolyunya (27 commits)")

### Embed Badge

![Health badge](/badges/kolyunya-wiki-parser/health.svg)

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

###  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)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46143.1k6](/packages/jstewmc-rtf)[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)
