Skip to content

Commit 2499e84

Browse files
committed
Clean up setup page
1 parent dbe5df0 commit 2499e84

1 file changed

Lines changed: 49 additions & 44 deletions

File tree

docs/SETUP.md

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,43 +57,12 @@ This creates a `.phpantom.toml` in the current directory. Currently supported se
5757

5858
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.
5959

60-
### Indexing Strategy
61-
62-
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.
63-
64-
The `strategy` setting controls this behaviour:
65-
66-
| Strategy | Behaviour |
67-
| --- | --- |
68-
| `"composer"` (default) | Use Composer's classmap when available, self-scan to fill gaps. Results match what `composer dump-autoload` knows about. |
69-
| `"self"` | Ignore Composer's classmap entirely and scan every PHP file in the workspace. Discovers all classes regardless of autoloading. |
70-
| `"none"` | Use only Composer's classmap with no fallback scanning. The most conservative option. |
71-
72-
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.
73-
74-
## Troubleshooting
75-
76-
### Classes from other files are not found
77-
78-
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:
79-
80-
1. **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. Set `strategy = "self"` in `.phpantom.toml` to scan all files.
81-
82-
2. **Composer's classmap is stale.** Run `composer dump-autoload` to regenerate it. PHPantom reads the classmap at startup.
83-
84-
3. **The class is in a directory not covered by `autoload` or `autoload-dev`.** Check that your `composer.json` PSR-4 mappings cover the directory where the class lives.
85-
86-
### Too many classes in completion lists
87-
88-
If you're seeing vendor-internal classes, duplicate framework classes (common in monorepos), or other noise, your indexing strategy may be too broad. The default `"composer"` strategy only surfaces classes that Composer's autoloader can load, which filters out this noise. If you previously set `strategy = "self"`, consider switching back to `"composer"`.
89-
9060
## Editor Setup
9161

9262
PHPantom communicates over stdin/stdout using the standard [Language Server Protocol](https://microsoft.github.io/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.
9363

94-
---
95-
96-
### Zed
64+
<details>
65+
<summary><b>Zed</b></summary>
9766

9867
A Zed extension is included in the `zed-extension/` directory:
9968

@@ -116,9 +85,10 @@ To make PHPantom the default PHP language server, add to your Zed `settings.json
11685
}
11786
```
11887

119-
---
88+
</details>
12089

121-
### Neovim
90+
<details>
91+
<summary><b>Neovim</b></summary>
12292

12393
```lua
12494
vim.lsp.config['phpantom'] = {
@@ -129,9 +99,10 @@ vim.lsp.config['phpantom'] = {
12999
vim.lsp.enable('phpantom')
130100
```
131101

132-
---
102+
</details>
133103

134-
### VS Code
104+
<details>
105+
<summary><b>VS Code</b></summary>
135106

136107
1. **Install a generic LSP client extension**
137108

@@ -154,9 +125,10 @@ vim.lsp.enable('phpantom')
154125
* Add the Language ID: `php`
155126
* Restart VS Code
156127
157-
---
128+
</details>
158129
159-
### PHPStorm
130+
<details>
131+
<summary><b>PHPStorm</b></summary>
160132
161133
1. **Download PHPantom LSP binary**
162134
@@ -172,15 +144,16 @@ vim.lsp.enable('phpantom')
172144
173145
* Name: `PHPantom`
174146
* Command: path to your PHPantom binary
175-
* Mapping: add a new Language and set it to `PHP`
147+
* Mapping: set `PHP` on both the **Language** tab and the **File Type** tab (the dialogs are identical). Setting both ensures PHPStorm activates the server reliably.
176148
177-
<img width="779" height="645" alt="Screenshot From 2026-02-21 00-28-37" src="https://github.com/user-attachments/assets/2da88e68-d012-476e-82e7-977dbfcd9653" />
149+
<img width="779" height="645" alt="PHPStorm new language server dialog" src="https://github.com/user-attachments/assets/2da88e68-d012-476e-82e7-977dbfcd9653" />
178150
179-
<img width="779" height="645" alt="Screenshot From 2026-02-21 00-32-24" src="https://github.com/user-attachments/assets/62358f9e-973c-487d-ac17-098d7dab007e" />
151+
<img width="779" height="645" alt="PHPStorm language server mapping dialog" src="https://github.com/user-attachments/assets/62358f9e-973c-487d-ac17-098d7dab007e" />
180152
181-
---
153+
</details>
182154
183-
### Sublime Text
155+
<details>
156+
<summary><b>Sublime Text</b></summary>
184157
185158
> [!NOTE]
186159
> This configuration is untested. If you get it working (or run into issues), please [open an issue](../../issues).
@@ -198,3 +171,35 @@ With [LSP for Sublime Text](https://github.com/sublimelsp/LSP):
198171
}
199172
}
200173
```
174+
175+
</details>
176+
177+
## Indexing Strategy
178+
179+
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.
180+
181+
The `strategy` setting controls this behaviour:
182+
183+
| Strategy | Behaviour |
184+
| --- | --- |
185+
| `"composer"` (default) | Use Composer's classmap when available, self-scan to fill gaps. Results match what `composer dump-autoload` knows about. |
186+
| `"self"` | Ignore Composer's classmap entirely and scan every PHP file in the workspace. Discovers all classes regardless of autoloading. |
187+
| `"none"` | Use only Composer's classmap with no fallback scanning. The most conservative option. |
188+
189+
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.
190+
191+
## Troubleshooting
192+
193+
### Classes from other files are not found
194+
195+
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:
196+
197+
1. **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. Set `strategy = "self"` in `.phpantom.toml` to scan all files.
198+
199+
2. **Composer's classmap is stale.** Run `composer dump-autoload` to regenerate it. PHPantom reads the classmap at startup.
200+
201+
3. **The class is in a directory not covered by `autoload` or `autoload-dev`.** Check that your `composer.json` PSR-4 mappings cover the directory where the class lives.
202+
203+
### Too many classes in completion lists
204+
205+
If you're seeing vendor-internal classes, duplicate framework classes (common in monorepos), or other noise, your indexing strategy may be too broad. The default `"composer"` strategy only surfaces classes that Composer's autoloader can load, which filters out this noise. If you previously set `strategy = "self"`, consider switching back to `"composer"`.

0 commit comments

Comments
 (0)