Skip to content

hightemp/php-lsp

Repository files navigation

php-lsp

Experimental Vibe Coded

PHP Language Server (LSP 3.17) written in Rust for Visual Studio Code.

Provides IDE-level features for PHP 7.4+ projects: diagnostics, hover, go-to-definition, completion, references, rename, and more.

Status

In development — MVP phase.

Features (planned for MVP)

  • Syntax error diagnostics (incremental, tree-sitter based)
  • Hover: type/signature/PHPDoc
  • Go to Definition (classes/functions/methods/properties/consts/variables)
  • Completion (members, statics, variables, namespaces, keywords)
  • Find All References (classes/functions/methods/properties/class const/global const/variables)
  • Rename symbol (classes/functions/methods/properties/class const/global const/variables)
  • Document/workspace symbols
  • Composer PSR-4 autoload support
  • Built-in PHP stubs (phpstorm-stubs)

Current gaps:

  • Cross-file variable analysis (variable references/rename are local-scope only by design)

Architecture

  • Server: Rust (tokio + tower-lsp-server + tree-sitter-php)
  • Client: VS Code extension (TypeScript + vscode-languageclient)
  • Transport: stdio (JSON-RPC 2.0)

Building

Prerequisites

  • Rust 1.85+ (rustup update stable)
  • Node.js 20+ and npm
  • Git (for submodules)

Quick start (Makefile)

make # build server + client + stubs → .vsix make install # build + install extension into VS Code

All available targets:

Command Description
make / make package Full build: server + client + stubs → .vsix
make install Build and install .vsix into VS Code
make server Build Rust binary for host platform
make server-all Cross-compile server for all 6 platforms
make package-all Universal .vsix with all platform binaries
make client npm ci + build extension JS
make stubs Init submodule + bundle phpstorm-stubs
make check Lint + test (Rust & TypeScript)
make test Run Rust tests
make lint cargo fmt --check, clippy, tsc --noEmit
make fmt Auto-format Rust code
make clean Remove all build artefacts

Stubs submodule (server/data/stubs) is pulled automatically on first build if not initialized.

Manual steps

Server

cd server cargo build --release

Client (VS Code extension)

cd client npm ci npm run build

Packaging VSIX

# 1. Build server binary for current platform → client/bin/<platform>/ ./scripts/build-server.sh # 2. Bundle phpstorm-stubs → client/stubs/ ./scripts/bundle-stubs.sh # 3. Package VSIX cd client npx @vscode/vsce package

Cross-compilation

./scripts/build-server.sh x86_64-unknown-linux-gnu # specific target ./scripts/build-server.sh --all # all 6 targets (CI)

Project Structure

php-lsp/ ├── Makefile # Build automation ├── server/ # Rust LSP server (Cargo workspace) │ ├── data/stubs/ # phpstorm-stubs (git submodule) │ └── crates/ │ ├── php-lsp-server/ # Main binary │ ├── php-lsp-parser/ # tree-sitter PHP wrapper │ ├── php-lsp-index/ # Symbol index │ ├── php-lsp-completion/ # Completion engine │ └── php-lsp-types/ # Shared types ├── client/ # VS Code extension (TypeScript) ├── scripts/ # Build helpers (build-server.sh, bundle-stubs.sh) ├── test-fixtures/ # Test PHP projects └── docs/ # Documentation 

License

MIT

About

PHP Language Server (LSP 3.17) written in Rust for Visual Studio Code.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors