MCPcopy Index your code
hub / github.com/PHPantom-dev/phpantom_lsp

github.com/PHPantom-dev/phpantom_lsp @0.8.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.8.0 ↗ · + Follow
14,512 symbols 85,186 edges 448 files 3,596 documented · 25%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

PHPantom

Spookaphant

CI codecov crates

A fast, lightweight PHP language server written in Rust. Ready in seconds, uses a fraction of the RAM other language servers need, and stays responsive throughout. No indexing phase, no waiting.

[!NOTE] PHPantom is in active development. The core editing features are solid and used daily on production codebases.

Features

PHPantom focuses on deep type intelligence. Here's how it compares:

PHPantom Intelephense PHP Tools Phpactor PHPStorm
Common LSP features1
Workspace symbols 🚧
Semantic tokens
Linked editing
Extras2 💰 🚧 🚧
Diagnostics
PHPStan integration 🚧 🚧
Undefined variable 💰
Type errors 💰 🚧
Unused variable
Type Intelligence
Generics / @template 🚧 🚧
@mixin completion 💰 🚧
Array / object shapes 🚧 🚧
PHPStan types 🚧 🚧 🚧
Conditional return types 🚧
Closure parameter inference 🚧 🚧 🚧
Laravel 🚧 🧩
Refactoring
Rename 💰 💰
Common refactorings3 💰
Extract constant
Promote constructor parameter
Simplify expressions 💰
Performance
Time to ready < 1 s 1 min 25 s 3 min 17 s 15 min 39 s 19 min 38 s
RAM usage 59 MB 520 MB 3.9 GB 498 MB 2.0 GB
Disk cache 0 45 MB 0 4.1 GB 551 MB

🚧 = partial support. 🧩 = requires plugin. 💰 = paid tier.

1 Completion, hover, signature help, go-to-definition, find references, diagnostics, document symbols.

2 Auto-import, go-to implementation / type-definition, smart select, folding ranges, formatting, code lens, inlay hints, type hierarchy, document links.

3 Implement interface methods, extract method/function, extract/inline variable, generate constructor, generate getter/setter.

Performance measured on a production codebase: 21K PHP files, 1.5M lines of code (vendor + application).

Want to verify? Open examples/demo.php in your editor and trigger completion at the marked locations. It exercises every type intelligence feature in the table, including edge cases where tools diverge. For Laravel specifically, open examples/laravel/ — a standalone project with real Eloquent models, config, routes, views, and translations that exercises Eloquent property resolution, query builder chaining, scopes, custom collections, and go-to-definition for config keys, route names, and translation strings.

Context-Aware Intelligence

  • Smart PHPDoc completion. @throws detects uncaught exceptions in the method body, @param pre-fills from the signature, and tags are filtered to context and never suggested twice.
  • Array shape inference. Literal arrays offer key completion with no annotation. Nested shapes, spreads, and array functions like array_map preserve element types.
  • Closure parameter inference. $users->map(fn($u) => $u->name) infers $u as User from the collection's generic context.
  • Conditional return types. PHPStan-style conditional @return types resolve to the concrete branch at each call site.
  • Type aliases and shapes. @phpstan-type, @phpstan-import-type, and object{...} shapes all resolve through to completions.
  • Laravel. Eloquent relationships, scopes, accessors, casts, and Builder chains resolve end-to-end. Blade templates get completion, hover, go-to-definition, and diagnostics through virtual PHP preprocessing. No Larastan, no ide-helper, no database access required.
  • Everything else you'd expect. Generics, type narrowing, named arguments, destructuring, first-class callables, anonymous classes, @deprecated detection, and namespace segment drilling.

Project Awareness

PHPantom understands Composer projects out of the box, but works without setup on non-Composer projects too:

  • Autoloader-accurate results. Completions and go-to-definition only surface classes that Composer's autoloader can actually load, avoiding false positives from internal, inaccessible, or duplicate vendor classes. You see exactly what your application can use.
  • PSR-4 autoloading. Resolves classes across files on demand.
  • Classmap and file autoloading. autoload_classmap.php and autoload_files.php.
  • Embedded PHP stubs from phpstorm-stubs bundled in the binary, no runtime downloads needed.
  • Drupal project support. Detects Drupal projects via composer.json, resolves the web root, and indexes Drupal-specific directories and PHP extensions (.module, .install, .theme, etc.) with .gitignore bypassed so that Composer-managed core and contrib code is always available.
  • require_once discovery. Functions from required files are available for completion.
  • Go-to-implementation. Jump from an interface or abstract class to all concrete implementations. Scans open files, classmap, PSR-4 directories, and embedded stubs.

Documentation

Acknowledgements

PHPantom stands on the shoulders of:

  • Mago: the PHP parser that powers all of PHPantom's AST analysis.
  • PHPStan and Psalm: for their pioneering work in PHP static analysis and shaping the type ecosystem. PHPantom builds on PHPStan-informed type experience, with full support for @phpstan-* annotations.
  • JetBrains phpstorm-stubs: type information for the entire PHP standard library, embedded directly into the binary.
  • Phpactor: the PHP language server whose comprehensive test suite and benchmark fixtures informed PHPantom's own test coverage. Many of PHPantom's type inference fixtures were adapted from Phpactor's reflection tests.

License

MIT. See LICENSE.

Extension points exported contracts — how you extend this code

VirtualMemberProvider (Interface)
A provider that contributes virtual members to a class. Receives the class with traits and parents already merged (via [5 …
src/virtual_members/mod.rs
StaticInstanceInterface (Interface)
* StaticInstanceInterface is the interface for providing static instances to classes, * which can be used to obtain cla
benches/fixtures/yii/StaticInstanceInterface.php
Psr4Paths (Interface)
Uniform access to the path strings inside a PSR-4 value, regardless of whether it came from `autoload` or `autoload-dev`
src/composer.rs
GenericInterface (Interface)
@template T */
tests/phpstan_nsrt/enums.php
A (Interface)
* @template T1 */
tests/psalm_assertions/template_class_template_extends.php
ScaffoldingAstNodeInterface (Interface)
── Template-param @mixin scaffolding ───────────────────────────────────────
examples/demo.php
Arrayable (Interface)
* Arrayable is the interface that should be implemented by classes who want to support customizable representation of th
benches/fixtures/yii/Arrayable.php
ContainerInterface (Interface)
* @template T */
tests/phpstan_nsrt/generics.php

Core symbols most depended-on inside this repo

unwrap
called by 6699
tests/psalm_assertions/if_this_is.php
iter
called by 4924
src/names.rs
create_test_backend
called by 3297
tests/integration/common/mod.rs
clone
called by 3034
src/types.rs
unwrap
called by 1947
examples/demo.php
find
called by 1635
examples/demo.php
map
called by 1427
tests/phpstan_nsrt/generics.php
push
called by 1424
src/types.rs

Shape

Function 11,825
Method 1,894
Class 695
Enum 69
Interface 29

Languages

Rust87%
PHP12%
Python1%

Modules by API surface

examples/demo.php706 symbols
src/php_type.rs550 symbols
tests/integration/hover.rs332 symbols
tests/integration/completion_variables.rs289 symbols
tests/integration/completion_laravel.rs253 symbols
src/diagnostics/unknown_members/tests.rs194 symbols
src/completion/variable/forward_walk.rs174 symbols
src/code_actions/extract_function.rs173 symbols
src/types.rs163 symbols
tests/unit/docblock_parsing.rs159 symbols
tests/integration/diagnostics_type_errors.rs154 symbols
src/symbol_map/tests.rs154 symbols

Datastores touched

DB_DATABASEDatabase · 1 repos

For agents

$ claude mcp add phpantom_lsp \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact