|
1 | | -# PHPantom for VS Code and Cursor |
| 1 | +# PHPantom |
| 2 | + |
| 3 | +PHP language support for Visual Studio Code powered by [PHPantom](https://github.com/PHPantom-dev/phpantom_lsp), a fast language server with deep type intelligence, generics, and framework-awarness. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +- **Code completion.** Type-aware suggestions for symbols, keywords, and members with automatic use declaration insertion. |
| 10 | +- **Signature help.** Parameter hints for constructors, methods, and functions. |
| 11 | +- **Navigation.** Go to definition, type definition, implementation, find all references, and rename. |
| 12 | +- **Diagnostics.** Undefined symbols, type errors, argument count mismatches, deprecated usage, unused imports, and implementation errors. |
| 13 | +- **Hover.** Type information and PHPDoc documentation. |
| 14 | +- **Code actions.** Extract variable/method/constant, inline variable, generate constructor/getters/setters, implement interface methods, auto-import, and PHPDoc generation. |
| 15 | +- **Call hierarchy and type hierarchy.** |
| 16 | +- **Semantic tokens, inlay hints, and code lens.** |
| 17 | +- **Document highlight and workspace symbol search.** |
| 18 | +- **Formatting.** PSR-12 compatible, with optional Laravel Pint integration. |
| 19 | +- **Code folding and smart selection.** |
| 20 | +- **Document links** for include/require paths. |
| 21 | +- **Deep type intelligence.** Generics (`@template`), PHPStan/Psalm annotations, and framework-aware analysis including Laravel Eloquent. |
| 22 | + |
| 23 | +## Quick Start |
| 24 | + |
| 25 | +1. Disable the built-in VS Code PHP Language Features. |
| 26 | + - Go to `Extensions`. |
| 27 | + - Search for `@builtin php`. |
| 28 | + - Disable `PHP Language Features`. Leave `PHP Language Basics` enabled for syntax highlighting. |
| 29 | +2. Disable other PHP language servers (Intelephense, Phpactor, PHP Tools) to avoid duplicate content. |
| 30 | +3. Open a PHP project. PHPantom downloads and starts the language server automatically. |
| 31 | + |
| 32 | +To use a custom binary, set `phpantom.serverPath` to the path of your `phpantom_lsp` binary. You can build from source with `cargo install phpantom_lsp` or download a release from [GitHub](https://github.com/PHPantom-dev/phpantom_lsp/releases). |
| 33 | + |
| 34 | +## Settings |
| 35 | + |
| 36 | +| Setting | Default | Description | |
| 37 | +| --- | --- | --- | |
| 38 | +| `phpantom.serverPath` | `""` | Path to a custom `phpantom_lsp` binary. | |
| 39 | +| `phpantom.releaseTag` | `"latest"` | GitHub release tag to download. | |
| 40 | +| `phpantom.autoDownload` | `true` | Automatically download the server if not found. | |
| 41 | +| `phpantom.autoUpdate` | `true` | Check for newer releases periodically. | |
| 42 | +| `phpantom.updateCheckIntervalHours` | `24` | How often to check for updates (1-168 hours). | |
| 43 | +| `phpantom.trace.server` | `"off"` | Trace communication with the language server. | |
2 | 44 |
|
3 | | -[PHPantom](https://github.com/AJenbo/phpantom_lsp) is a fast PHP language server written in Rust. This extension starts `phpantom_lsp` automatically for PHP files in VS Code-compatible editors, including Cursor. |
4 | | - |
5 | | -On first activation, the extension looks for a server binary in this order: |
6 | | - |
7 | | -1. `phpantom.serverPath` |
8 | | -2. `phpantom_lsp` on `PATH` (`phpantom_lsp.exe` on Windows) |
9 | | -3. A cached binary in the extension global storage |
10 | | -4. A GitHub Releases download from `AJenbo/phpantom_lsp`, when `phpantom.autoDownload` is enabled |
11 | | - |
12 | | -When `phpantom.releaseTag` is `latest`, the extension also checks for newer PHPantom releases in the background on startup and periodically while active. If a newer downloaded binary becomes available, PHPantom asks whether to restart the language server now or use the update later. Background updates are skipped when `phpantom.serverPath` is set, `phpantom.autoDownload` is disabled, `phpantom.autoUpdate` is disabled, or a `phpantom_lsp` binary on `PATH` has priority. |
13 | | - |
14 | | -The language server communicates over stdio and attaches to files with language ID `php`. A PHPantom status bar item shows whether the server is starting, ready, checking for updates, waiting for restart, stopped, or failed. Click it to open the PHPantom output channel. |
15 | | - |
16 | | -On startup, the PHPantom output channel logs the extension version, workspace path, active server source, server path, and auto-update state. |
17 | | - |
18 | | -## Cursor |
19 | | - |
20 | | -Once published, install PHPantom from Open VSX in Cursor's Extensions view. |
21 | | - |
22 | | -For a local package: |
23 | | - |
24 | | -1. Run `npm install` in this directory. |
25 | | -2. Run `npm run package`. |
26 | | -3. In Cursor, run `Extensions: Install from VSIX...`. |
27 | | -4. Select the generated `.vsix` file. |
28 | | - |
29 | | -## VS Code |
30 | | - |
31 | | -Install the generated `.vsix` with `Extensions: Install from VSIX...`, or install from the marketplace if PHPantom is published there in the future. |
32 | | - |
33 | | -## Configuration |
34 | | - |
35 | | -`phpantom.serverPath` |
36 | | - |
37 | | -Absolute path to a custom `phpantom_lsp` binary. When set, this overrides PATH lookup and downloads. Changing this setting restarts the PHPantom language server. |
38 | | - |
39 | | -`phpantom.releaseTag` |
40 | | - |
41 | | -GitHub release tag to download. The default is `latest`, which uses the latest stable GitHub release. Changing this setting restarts the PHPantom language server. |
42 | | - |
43 | | -`phpantom.autoDownload` |
44 | | - |
45 | | -Automatically download `phpantom_lsp` when no configured or PATH binary is available. Enabled by default. |
46 | | - |
47 | | -`phpantom.autoUpdate` |
48 | | - |
49 | | -Automatically check for newer downloaded `phpantom_lsp` releases when `phpantom.releaseTag` is `latest`. Enabled by default. Ignored when `phpantom.serverPath` is set. |
50 | | - |
51 | | -`phpantom.updateCheckIntervalHours` |
| 45 | +## Commands |
52 | 46 |
|
53 | | -How often to check for newer PHPantom language server releases while the extension is active. The extension also checks once on startup without blocking activation. Defaults to `24`. |
| 47 | +- **PHPantom: Restart Language Server.** Restart the language server. |
| 48 | +- **PHPantom: Show Output.** Open the PHPantom output channel. |
| 49 | +- **PHPantom: Show Server Version.** Display the running server version. |
| 50 | +- **PHPantom: Check for Server Update.** Check for a newer server binary. |
| 51 | +- **PHPantom: Clear Downloaded Language Server.** Remove cached server binaries. |
54 | 52 |
|
55 | | -`phpantom.trace.server` |
| 53 | +## How It Works |
56 | 54 |
|
57 | | -Controls Language Server Protocol tracing. Values are `off`, `messages`, and `verbose`. |
| 55 | +On activation the extension locates a server binary in this order: |
58 | 56 |
|
59 | | -## Commands |
| 57 | +1. `phpantom.serverPath` setting |
| 58 | +2. `phpantom_lsp` on `PATH` |
| 59 | +3. A previously cached binary |
| 60 | +4. Download from GitHub Releases (when `phpantom.autoDownload` is enabled) |
60 | 61 |
|
61 | | -- `PHPantom: Restart Language Server` |
62 | | -- `PHPantom: Show Output` |
63 | | -- `PHPantom: Show Server Version` |
64 | | -- `PHPantom: Check for Server Update` |
65 | | -- `PHPantom: Clear Downloaded Language Server` |
| 62 | +When `phpantom.releaseTag` is `"latest"`, the extension checks for updates on startup and periodically while active. A status bar item shows the server state. |
66 | 63 |
|
67 | 64 | ## Troubleshooting |
68 | 65 |
|
69 | | -If the binary download fails, open the `PHPantom` output channel. The error lists the release tag, platform, expected asset names, and available assets when GitHub returns a release. You can also download a binary from the PHPantom GitHub Releases page and set `phpantom.serverPath`. |
| 66 | +If the download fails, open the PHPantom output channel for details. You can always download a binary manually and set `phpantom.serverPath`. |
70 | 67 |
|
71 | | -If your platform is unsupported, build `phpantom_lsp` from source and point `phpantom.serverPath` at the local binary. |
| 68 | +If your platform is unsupported, build from source and point `phpantom.serverPath` at the result. |
72 | 69 |
|
73 | | -If diagnostics appear twice, another PHP language server such as Intelephense, Phpactor, or PHP Tools may also be active. Disable the duplicate PHP LSP extension for the workspace. |
| 70 | +## License |
74 | 71 |
|
75 | | -To use a local binary, build PHPantom from source or download a release manually, then set `phpantom.serverPath` to the absolute path of `phpantom_lsp` or `phpantom_lsp.exe`. |
| 72 | +[MIT](LICENSE) |
76 | 73 |
|
77 | | -## Security |
| 74 | +--- |
78 | 75 |
|
79 | | -Downloaded binaries come from [AJenbo/phpantom_lsp](https://github.com/AJenbo/phpantom_lsp) GitHub Releases. The extension verifies release asset size and verifies GitHub SHA-256 digests when GitHub publishes them. If upstream publishes standalone checksum files in the future, the extension should verify those checksums as well. |
| 76 | +See the [PHPantom language server changelog](https://github.com/PHPantom-dev/phpantom_lsp/blob/main/docs/CHANGELOG.md) for improvements to type intelligence, diagnostics, and completions. |
0 commit comments