PHPackages                             t3ide/language-server-protocol - 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. t3ide/language-server-protocol

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

t3ide/language-server-protocol
==============================

Langauge Server Protocol for PHP (transpiled)

v3.17.0(2mo ago)0212MITPHPPHP ^8.1

Since Mar 1Pushed 2mo agoCompare

[ Source](https://github.com/t3ide/language-server-protocol)[ Packagist](https://packagist.org/packages/t3ide/language-server-protocol)[ RSS](/packages/t3ide-language-server-protocol/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (2)

PHP Language Server Protocol Generator
======================================

[](#php-language-server-protocol-generator)

This package *transpiles* the `microsoft/lsprotocol/generator/lsp.json` to PHP, providing the protocol classes required to create Language Server with PHP.

A lot of inspiration and some code was taken from `phpactor/language-server-protocol`. The difference is, that the code generation is fully based on PHP and the protocol classes are more complete.

Allthough the `lsp.json` states, that the version of the LSP is a specific version, there are some code parts, which are "proposed" or from future versions. Allthough this is part of the official protocol definition, part of the official code generator inside the `microsoft/lsprotocol` project and also part of the official `vscode-language-server-protocol` project, we filter those parts out in the default build. You can build your own set of classes including those future parts of the specification, but you need to be careful when using them

This Library will stick to the current official set of features.

Generation
----------

[](#generation)

Generating the code:

- `composer build`

Generate a specific protocol subset (for example only features up to 3.17.0):

- `php generator/generate.php --max-version=3.17.0`

The version filter keeps referenced types even if they are marked with a newer `since` value (for example type renames with older `sinceTags`) so generation stays consistent.

Running the PHP tests:

- `composer integrate`

Usage
-----

[](#usage)

### Deserialization

[](#deserialization)

This library will use the type information from the `lsp.json` to generate `fromArray` static constructors for each type:

```
$item = CompletionItem::fromArray([
    'label' => 'Foobar',
    'kind' => 1,
    'detail' => 'This is foobar',
    'documentation' => [
        'kind' => 'markdown',
        'value' => 'Foobar',
    ],
    'additionalTextEdits' => [
        [
            'range' => [
                'start' => [
                    'line' => 5,
                    'character' => 10,
                ],
                'end' => [
                    'line' => 10,
                    'character' => 10,
                ],
            ],
            'newText' => 'Foobar',
        ],
    ],
    'command' => [
        'title' => 'Foobar',
        'command' => 'my.command',
    ],
]);
```

Will return a fully hydrated completion item with concrete sub-types.

**NOTE**: that when deserializing from a language server client request, it is probably a good idea to ignore additional parameters (the second argument to `fromArray`). This is because it is perfectly valid to pass unknown properties to some of the LSP objects.

### Serialization

[](#serialization)

Properties in classes are public to enable JSON serialization. Call `json_encode($lspObject)` to get the valid LSP JSON object.

Notes on some design decisions
------------------------------

[](#notes-on-some-design-decisions)

The LSP is defined with extending classes and using mixins. In PHP there are no mixins or multiple inheritance. So for now each class simply has no inheritance. To support mixins and extending classes, all classes would need to be based on interfaces so properties couldn't be used but getters and setters. This would lead to much more files and code. If there are no critical problems with the current design, this change will be avoided.

Contributing
------------

[](#contributing)

This package is open source and welcomes contributions! Feel free to open a pull request on this repository.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance85

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

78d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/574900a5737f32ea8a42095f4e16c43ffeb27d5c99d74644f939ca45cfd145ad?d=identicon)[Teddytrombone](/maintainers/Teddytrombone)

---

Top Contributors

[![Teddytrombone](https://avatars.githubusercontent.com/u/14216933?v=4)](https://github.com/Teddytrombone "Teddytrombone (13 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/t3ide-language-server-protocol/health.svg)

```
[![Health](https://phpackages.com/badges/t3ide-language-server-protocol/health.svg)](https://phpackages.com/packages/t3ide-language-server-protocol)
```

###  Alternatives

[chenkby/yii2-region

Yii2中国省市区三级联动

325.1k](/packages/chenkby-yii2-region)

PHPackages © 2026

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