PHPackages                             lsparrot/lsparrot - 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. lsparrot/lsparrot

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

lsparrot/lsparrot
=================

PHP extension for LSParrot LSP support

0.0.4(1mo ago)115[1 issues](https://github.com/LSParrot/ext-lsparrot/issues)[5 PRs](https://github.com/LSParrot/ext-lsparrot/pulls)0BSDCPHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.1 || ~8.5.0CI passing

Since Jun 15Pushed 1w agoCompare

[ Source](https://github.com/LSParrot/ext-lsparrot)[ Packagist](https://packagist.org/packages/lsparrot/lsparrot)[ GitHub Sponsors](https://github.com/zeriyoshi)[ RSS](/packages/lsparrot-lsparrot/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (12)Versions (5)Used By (0)

LSParrot PHP Extension (beta)
=============================

[](#lsparrot-php-extension-beta)

LSParrot is a PHP extension that runs a Language Server Protocol server from the PHP CLI runtime itself. It uses the host PHP parser, Zend AST, Composer metadata, and optional static analyzers to provide PHP language features without requiring a separate PHP library process.

The extension entrypoint is:

```
LSParrot\start_lsp(array $options = []): void;
```

LSP protocol messages are read from stdin and written to stdout. The server is intended to be launched by an editor client such as the LSParrot VS Code extension.

Disclaimer
----------

[](#disclaimer)

**This software is typical AI slop software, containing code generated by AI (LLMs). That said, the generated code has been reviewed to the extent possible and corrected as appropriate. Even so, since I am the sole reviewer, it is expected to be substantially inferior to software written entirely by hand from scratch. Please use it only if you accept that.**

**All code in this project has been implemented according to my intent. However, legal views differ on the copyright status of code generated with LLMs, so this project is licensed under the 0BSD license.**

Requirements
------------

[](#requirements)

- PHP CLI SAPI matching the package constraints in `composer.json`(`~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.1 || ~8.5.0`)
- A loadable `lsparrot` PHP extension
- Composer metadata for project-wide class/function discovery
- Optional project-local PHPStan and/or Psalm for richer diagnostics and type information

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

[](#installation)

PIE is the preferred installation path:

```
pie install lsparrot/lsparrot
```

After installation, verify that the extension is loadable:

```
php -dextension=lsparrot -r 'var_export(LSParrot\lsparrot_version());'
```

For local development, build the extension through the standard PHP extension flow:

```
cd ext
phpize
./configure --enable-lsparrot
make -j"$(nproc)"
make install
```

Running
-------

[](#running)

The default mode enables the LSParrot Engine and automatically enables supported project analyzers when their binaries are found in the Composer project or `PATH`:

```
php -dextension=lsparrot -r 'LSParrot\start_lsp();'
```

To force LSParrot Engine-only behavior:

```
php -dextension=lsparrot -r 'LSParrot\start_lsp(["analyzer" => "lsparrot"]);'
```

To request analyzers explicitly:

```
php -dextension=lsparrot -r 'LSParrot\start_lsp(["analyzer" => ["phpstan", "psalm"]]);'
```

`analyzer` is the supported option name. The British spelling `analyser` is not accepted.

PHP API
-------

[](#php-api)

- `LSParrot\start_lsp(array $options = []): void`starts the LSP server. It requires the CLI SAPI.
- `LSParrot\lsparrot_parse(string $code, ?string $uri = null): array`returns tokens, a line map, Zend AST data when parsing succeeds, and PHP parser diagnostics.
- `LSParrot\lsparrot_tokens(string $code, ?string $uri = null): array`returns token metadata from the PHP lexer.
- `LSParrot\lsparrot_version(): array`returns PHP version, extension version, CLI status, and process-control availability.

LSP Features
------------

[](#lsp-features)

LSParrot currently advertises and implements these LSP capabilities:

- text document sync, open/change/save/close handling, and diagnostics
- completion with trigger characters for PHP expressions, member access, namespaces, PHPDoc, array shapes, and imports
- hover, definition, references, document highlight, implementation lookup, and rename
- signature help and parameter-name inlay hints
- document symbols and workspace symbols
- formatting and range formatting
- quick fixes, organize imports, and import text edits
- code lens for override navigation
- custom `lsparrot.php/status`, `lsparrot.php/analyzerStatus`, `lsparrot.php/preloadThisMembers`, and `lsparrot.php/invalidateMemberCache`messages used by LSParrot clients

The built-in LSParrot Engine can infer and complete a growing set of language constructs, including Composer project symbols, local scope variables, `$this`and inherited members, static members, constructor-promoted properties, constants, function and method signatures, return types, PHPDoc `@var` / `@param` / `@return` / `@method` / `@template` information, generic array elements, PHPDoc type aliases, and array-shape keys.

Project Index
-------------

[](#project-index)

On initialization LSParrot builds a project symbol index from Composer metadata and PHP source files. It understands Composer classmap, PSR-4, PSR-0, declared classes, interfaces, traits, enums, functions, and constants.

Workspace project symbols are preferred over vendor symbols. Analyzer project roots are scoped to Composer projects and avoid treating vendor packages as workspace roots.

The serialized project index is cached at:

```
.lsparrot/lsparrot-index.bin

```

Set `LSPARROT_NO_INDEX=1` to disable loading and saving this cache.

Static Analyzer Integration
---------------------------

[](#static-analyzer-integration)

LSParrot always runs its own engine. Static analyzers are optional enrichments for diagnostics, hover types, member completion, template resolution, and complex PHPDoc type information.

Supported analyzer modes:

- `auto`: enable available project-local analyzers
- `lsparrot`: use only the built-in engine
- `phpstan`: use PHPStan in addition to LSParrot
- `psalm`: use Psalm CLI in addition to LSParrot
- `psalm-ls`: proxy Psalm Language Server in addition to LSParrot
- `["phpstan", "psalm"]` or similar arrays: enable multiple requested analyzers

Analyzer binaries are resolved from the Composer project first, including a custom Composer `bin-dir`, and then from `PATH`. Nested Composer projects under the workspace can be used when their own analyzer binaries are present.

When a project does not provide analyzer config, LSParrot generates LSP-specific config under `.lsparrot/` and defaults PHPStan/Psalm levels to `6`.

Analyzer files and caches are written under:

```
.lsparrot/phpstan/
.lsparrot/psalm/
.lsparrot/shadow/

```

Options
-------

[](#options)

`LSParrot\start_lsp()` accepts these options:

OptionDefaultDescription`analyzer``"auto"``"auto"`, `"lsparrot"`, `"phpstan"`, `"psalm"`, `"psalm-ls"`, or an array containing `"phpstan"`, `"psalm"`, and/or `"psalm-ls"`.`symbolIndex.size``"64M"`Maximum size for the in-memory symbol index. Accepts bytes as an integer or strings with `K`, `M`, or `G` suffixes.`workers.count``0`Analyzer parallelism. `0` auto-detects the CPU count when generating analyzer config.`workers.analyzerDiagnosticsTimeout``60.0`Timeout in seconds for analyzer diagnostics commands.`memoryLimit``"-1"`Analyzer `--memory-limit` value.`workerPhpArgs``[]`Extra PHP CLI arguments used when LSParrot launches PHP-based analyzer binaries.`phpstanLevel``6`Default PHPStan level when no project config is present.`phpstan.level``6`Nested form of the PHPStan level option.`psalmLevel``6`Default Psalm level when no project config is present.`psalm.level``6`Nested form of the Psalm level option.`psalm.transport``"auto"``"auto"`, `"cli"`, `"languageServer"`, `"language-server"`, or `"lsp"`.`psalm.onChange``true`Forward document changes to Psalm LS.`psalm.enableAutocomplete``true`Use Psalm LS completion.`psalm.enableDiagnostics``true`Use Psalm LS diagnostics.`psalm.enableHover``true`Use Psalm LS hover type information.`psalm.enableDefinition``true`Use Psalm LS definitions when available.`psalm.enableSignatureHelp``true`Use Psalm LS signature help when available.`psalm.showInfo``false`Include Psalm informational diagnostics.`psalm.liveDeadCodeDiagnostics``false`Enable Psalm live dead-code diagnostics in generated config.`psalm.inMemory``false`Use Psalm LS in-memory behavior where supported.`psalm.onChangeDebounceMs``500`Debounce interval for Psalm LS change notifications.`psalm.maxResponseWaitMs``200`Maximum wait for synchronous Psalm LS-backed responses.Example:

```
LSParrot\start_lsp([
    'analyzer' => ['phpstan', 'psalm'],
    'symbolIndex' => ['size' => '128M'],
    'workers' => [
        'count' => 4,
        'analyzerDiagnosticsTimeout' => 30,
    ],
    'memoryLimit' => '1G',
    'workerPhpArgs' => ['-dmemory_limit=1G'],
    'phpstan' => ['level' => 8],
    'psalm' => [
        'transport' => 'languageServer',
        'maxResponseWaitMs' => 500,
    ],
]);
```

Development
-----------

[](#development)

Run the PHPT suite from `ext/` after building:

```
cd ext
NO_INTERACTION=1 make test TESTS="--show-diff --context 20"
```

The extension sources live under `ext/`. The directories whose names start with `example` are for manual behavior checks and are not test fixtures.

License
-------

[](#license)

0BSD

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance75

Regular maintenance activity

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

4

Last Release

45d ago

### Community

Maintainers

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

---

Top Contributors

[![zeriyoshi](https://avatars.githubusercontent.com/u/10289597?v=4)](https://github.com/zeriyoshi "zeriyoshi (6 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (3 commits)")

---

Tags

lspphpphpstanpsalm

###  Code Quality

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[opensky/runtime-config-bundle

This bundle provides a way to inject parameters into services at runtime by exposing a RuntimeParameterBag service, which functions exactly like Symfony2's own ParameterBags.

10949.6k1](/packages/opensky-runtime-config-bundle)[bolt/bolt-extension-starter

103.3k](/packages/bolt-bolt-extension-starter)

PHPackages © 2026

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