PHPackages                             wikimedia/webidl - 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. wikimedia/webidl

ActiveLibrary

wikimedia/webidl
================

WebIDL parser for PHP

v1.2.1(2mo ago)11.9k↓33.3%MITPHPPHP &gt;=8.1

Since Jan 28Pushed 2mo ago18 watchersCompare

[ Source](https://github.com/wikimedia/mediawiki-libs-WebIDL)[ Packagist](https://packagist.org/packages/wikimedia/webidl)[ Docs](https://www.mediawiki.org/wiki/WebIDL)[ RSS](/packages/wikimedia-webidl/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (9)Used By (0)

WebIDL
======

[](#webidl)

**WebIDL** is a parser for [Web IDL](https://heycam.github.io/webidl/), a language [to specify web APIs in interoperable way](https://heycam.github.io/webidl/#introduction). This library supports PHP, and is in the same spirit as (but shares no code with) [webidl2](https://github.com/w3c/webidl2.js) for JavaScript and the browser.

Report issues on [Phabricator](https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?projects=Parsoid&title=WebIDL:%20).

Install
-------

[](#install)

This package is [available on Packagist](https://packagist.org/packages/wikimedia/webidl):

```
$ composer require wikimedia/webidl
```

Usage
-----

[](#usage)

WebIDL provides one function, `parse`, which converts a WebIDL string into a syntax tree.

```
use Wikimedia\WebIDL;

$tree = WebIDL::parse("string of WebIDL");
```

The `parse()` method optionally takes an option array with the following keys:

- `concrete`: Boolean indicating whether the result should include an EOF node or not.
- `sourceName`: The source name, typically a filename. Errors and validation objects can indicate their origin if you pass a value.

AST (Abstract Syntax Tree)
--------------------------

[](#ast-abstract-syntax-tree)

The AST output matches the [webidl2 AST docs](https://github.com/w3c/webidl2.js#ast-abstract-syntax-tree)with PHP associative arrays replacing JavaScript objects in the usual way (ie, JSON output deserialized in PHP with `json_decode($ast, true)`).

Briefly, the WebIDL input:

```
interface _Iroha : _Magic {};
_Iroha includes _Color;

```

Gives the following PHP array after parsing:

```
[
     [
       "type" => "interface",
       "name" => "Iroha",
       "inheritance" => "Magic",
       "members" => [],
       "extAttrs" => [],
       "partial" => false,
     ],
     [
       "type" => "includes",
       "extAttrs" => [],
       "target" => "Iroha",
       "includes" => "Color",
     ],
]
```

Refer to the `webidl2` docs or the files in `tests/syntax/` for more details.

Tests
-----

[](#tests)

Test cases in `tests/invalid` and `tests/syntax` come from [`webidl2.js`](https://github.com/w3c/webidl2.js/tree/gh-pages/test). If you update them from upstream, please update the commit hash in `tests/WebIDLTest.php` as well.

```
$ composer test
```

Hacking
-------

[](#hacking)

The grammar is written using [wikipeg](wikipeg), a PEG parser generator that can output either JS or PHP code. To regenerate the parser after changes are made to `Grammar.php`, run:

```
$ npm install # once, to install the JS version of wikipeg
$ composer wikipeg
```

License and Credits
-------------------

[](#license-and-credits)

The initial version of this code was written by C. Scott Ananian and is Copyright (c) 2021 Wikimedia Foundation.

This code is distributed under the MIT license; see LICENSE for more info.

Test cases used by this code were part of the [webidl2.js](https://github.com/w3c/webidl2.js) package, which is Copyright (c) 2014 Robin Berjon and also distributed under the MIT license.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance86

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 77.2% 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 ~263 days

Recently: every ~413 days

Total

8

Last Release

84d ago

PHP version history (4 changes)v1.0.0PHP &gt;=7.2.0

v1.0.3PHP &gt;=7.2.9

v1.1.0PHP &gt;=7.4

v1.2.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b94d9718c06ec7c3fd7a104bc44966fb7464b9ec7411582343ea35a7a6a85f08?d=identicon)[mediawiki](/maintainers/mediawiki)

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

![](https://www.gravatar.com/avatar/3551c2aefb299a0c45807f7677f5b26d8a5be4a4af359b4bf4fabbdd1f2b990e?d=identicon)[cscott](/maintainers/cscott)

---

Top Contributors

[![cscott](https://avatars.githubusercontent.com/u/156080?v=4)](https://github.com/cscott "cscott (44 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (9 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (4 commits)")

---

Tags

webidlwikipeg

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikimedia-webidl/health.svg)

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

###  Alternatives

[wikimedia/parsoid

Parsoid, a bidirectional parser between wikitext and HTML5

171524.3k1](/packages/wikimedia-parsoid)

PHPackages © 2026

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