PHPackages                             edin/lexicon - 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. edin/lexicon

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

edin/lexicon
============

Attribute-driven PHP lexer and scanner library with enum tokens, trivia preservation, modes, diagnostics, and JSON/XML matchers.

v0.2.0(2d ago)01↑2900%MITPHPPHP ^8.2CI passing

Since Jun 7Pushed 2d agoCompare

[ Source](https://github.com/edin/Lexicon)[ Packagist](https://packagist.org/packages/edin/lexicon)[ RSS](/packages/edin-lexicon/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Lexicon
=======

[](#lexicon)

Attribute-driven PHP scanner/lexer library.

Lexicon lets you define tokens with PHP enums and attributes:

```
$tokens = Lexer::from(MyToken::class)->scan($source);
```

It supports fixed tokens, matcher-backed tokens, trivia preservation, unknown token recovery, token spans, diagnostics, debug tables, and user-defined lexer modes.

Install
-------

[](#install)

```
composer install
```

Test
----

[](#test)

```
composer test
```

Documentation
-------------

[](#documentation)

- [Quick Start](docs/quick-start.md)
- [Token Attributes](docs/token-attributes.md)
- [Matchers](docs/matchers.md)
- [Modes](docs/modes.md)
- [Parser Primitives](docs/parser.md)
- [Debugging Tokens](docs/debugging.md)
- [Examples](docs/examples.md)

Run Examples
------------

[](#run-examples)

```
php examples/basic-scanner.php
php examples/json-scanner.php
php examples/xml-scanner.php
php examples/math.php
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance99

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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

Total

2

Last Release

2d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82bb42da001bbd10ee7a34aa349e7cf749cb509408f40170fa9cfdb80984ca87?d=identicon)[EdinOmeragic](/maintainers/EdinOmeragic)

---

Top Contributors

[![edin](https://avatars.githubusercontent.com/u/572400?v=4)](https://github.com/edin "edin (5 commits)")

---

Tags

attributeslexerscannerjsonxmlenumparserlexertokenizerattributesscanner

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/edin-lexicon/health.svg)

```
[![Health](https://phpackages.com/badges/edin-lexicon/health.svg)](https://phpackages.com/packages/edin-lexicon)
```

###  Alternatives

[cerbero/json-parser

Zero-dependencies pull parser to read large JSON from any source in a memory-efficient way.

803550.1k5](/packages/cerbero-json-parser)[orchestra/parser

XML Document Parser for Laravel and PHP

4591.7M6](/packages/orchestra-parser)[goetas-webservices/xsd-reader

Read any XML Schema (XSD) programmatically with PHP

615.0M19](/packages/goetas-webservices-xsd-reader)[strscan/strscan

Simple string tokenizer for lexical scanning operations

13154.3k2](/packages/strscan-strscan)[open-code-modeling/json-schema-to-php

Parses JSON schema files and provides an API to easily generate code from JSON schema.

111.0k2](/packages/open-code-modeling-json-schema-to-php)

PHPackages © 2026

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