Download the latest binary for your platform from GitHub Releases. Available for:
x86_64-unknown-linux-gnuaarch64-unknown-linux-gnux86_64-apple-darwinaarch64-apple-darwinx86_64-pc-windows-msvc
See BUILDING.md for full instructions. Quick version:
cargo build --release
# Binary is at target/release/phpantom_lspPHPantom communicates over stdin/stdout using the standard Language Server Protocol. Any editor with LSP support can use it. Point the client at the phpantom_lsp binary with php as the file type. No special initialization options are required.
Zed
A Zed extension is included in the zed-extension/ directory:
- Ensure you have
rustcavailable in your$PATH. This is part of the Rust toolchain - Open Zed
- Open the Extensions panel
- Click Install Dev Extension
- Select the
zed-extension/directory
The extension automatically downloads the correct pre-built binary from GitHub releases for your platform. If you'd prefer to use a locally built binary, ensure phpantom_lsp is on your PATH and the extension will use it instead.
To make PHPantom the default PHP language server, add to your Zed settings.json:
{
"languages": {
"PHP": {
"language_servers": ["phpantom_lsp", "!intelephense", "!phpactor", "!phptools", "..."]
}
}
}Neovim
vim.lsp.config['phpantom'] = {
cmd = { '/path/to/phpantom_lsp' },
filetypes = { 'php' },
root_markers = { 'composer.json', '.git' },
}
vim.lsp.enable('phpantom')VS Code
-
Install a generic LSP client extension
-
Recommended: Generic LSP Client (v2)
-
Install via VS Code Marketplace:
zsol.vscode-glspc
-
-
Download PHPantom LSP binary
- Get it from GitHub Releases
- Extract the binary and place it in a preferred location
-
Configure the extension
- Open VS Code settings for Generic LSP Client (v2)
- Set the path to your PHPantom binary
- Add the Language ID:
php - Restart VS Code
PHPStorm
-
Download PHPantom LSP binary
- Get it from GitHub Releases
- Extract the binary to a preferred location
-
Install and configure LSP plugin
-
Go to Editor → Plugins and install LSP4IJ
-
Restart PHPStorm
-
Navigate to Languages & Frameworks → Language Servers
-
Click + to add a new server
- Name:
PHPantom - Command: path to your PHPantom binary
- Mapping: set
PHPon both the Language tab and the File Type tab (the dialogs are identical). Setting both ensures PHPStorm activates the server reliably.
- Name:
-
Sublime Text
With LSP for Sublime Text:
{
"clients": {
"phpantom": {
"enabled": true,
"command": ["/path/to/phpantom_lsp"],
"selector": "embedding.php",
"priority_selector": "source.php"
}
}
}Helix
Helix has built-in LSP support. Add PHPantom to your languages.toml (typically ~/.config/helix/languages.toml):
[language-server.phpantom]
command = "phpantom_lsp"
[[language]]
name = "php"
language-servers = ["phpantom"]Emacs (eglot)
[!NOTE] This configuration is untested. If you get it working (or run into issues), please open an issue.
Eglot is built into Emacs 29+. Add to your init.el:
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(php-mode . ("phpantom_lsp"))))Then open a PHP file and run M-x eglot.
Emacs (lsp-mode)
[!NOTE] This configuration is untested. If you get it working (or run into issues), please open an issue.
Add to your init.el:
(with-eval-after-load 'lsp-mode
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection '("phpantom_lsp"))
:activation-fn (lsp-activate-on "php")
:server-id 'phpantom)))Then open a PHP file and run M-x lsp.
Kate
[!NOTE] This configuration is untested. If you get it working (or run into issues), please open an issue.
Kate (KDE) has built-in LSP support. Open Settings → Configure Kate → LSP Client → User Server Settings and add:
{
"servers": {
"php": {
"command": ["/path/to/phpantom_lsp"],
"url": "https://github.com/AJenbo/phpantom_lsp"
}
}
}PHPantom works best with Composer projects. It reads composer.json to discover autoload directories and vendor packages, so completions and go-to-definition only surface classes that your autoloader can actually load. Projects without composer.json fall back to scanning every PHP file in the workspace.
PHPantom supports an optional per-project configuration file for settings like PHP version overrides and diagnostic toggles.
To generate a default config file with all options documented and commented out:
phpantom_lsp initThis creates a .phpantom.toml in the current directory. Currently supported settings:
[php]
# Override the detected PHP version (default: inferred from composer.json, or 8.5).
# version = "8.5"
[diagnostics]
# Report member access on subjects whose type could not be resolved.
# Useful for discovering gaps in type coverage. Off by default.
# unresolved-member-access = true
[indexing]
# How PHPantom discovers classes across the workspace.
# "composer" (default) - use Composer classmap, self-scan on fallback
# "self" - always self-scan, ignore Composer classmap
# "none" - no proactive scanning, Composer classmap only
# strategy = "composer"The file is optional. When absent, all settings use their defaults. New settings will be added as features land. Unknown keys are silently ignored, so the file is forward-compatible.
By default, PHPantom trusts Composer's autoloader to determine which classes exist in your project. This is intentional: it means completions, diagnostics, and go-to-definition reflect what your code will actually see at runtime. Classes that aren't autoloadable don't appear, because using them would be an error.
The strategy setting controls this behaviour:
| Strategy | Behaviour |
|---|---|
"composer" (default) |
Use Composer's classmap when available, self-scan to fill gaps. Results match what composer dump-autoload knows about. |
"self" |
Ignore Composer's classmap entirely and scan every PHP file in the workspace. Discovers all classes regardless of autoloading. |
"none" |
Use only Composer's classmap with no fallback scanning. The most conservative option. |
Most projects should leave this at the default. Change it to "self" if your project loads classes outside of Composer (custom autoloaders, require_once, legacy inclusion patterns). Be aware that "self" will also surface vendor-internal classes and potential duplicates that Composer's autoloader would never load.
PHPantom resolves cross-file classes through Composer's autoloading rules (PSR-4 mappings and the generated classmap). If a class exists in your project but PHPantom reports it as unknown, the most common causes are:
-
The class isn't Composer-autoloadable. If your project loads classes via
require_once,include, or a custom autoloader alongside Composer, those classes won't be discovered by default. Setstrategy = "self"in.phpantom.tomlto scan all files. -
Composer's classmap is stale. Run
composer dump-autoloadto regenerate it. PHPantom reads the classmap at startup. -
The class is in a directory not covered by
autoloadorautoload-dev. Check that yourcomposer.jsonPSR-4 mappings cover the directory where the class lives.