You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/SETUP.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ cargo build --release
23
23
24
24
## Project Requirements
25
25
26
-
PHPantom works with any PHP project. It reads `composer.json`when present to discover autoload directories and vendor packages, and falls back to scanning the workspace when not present.
26
+
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.
27
27
28
28
## Configuration
29
29
@@ -46,10 +46,47 @@ This creates a `.phpantom.toml` in the current directory. Currently supported se
46
46
# Report member access on subjects whose type could not be resolved.
47
47
# Useful for discovering gaps in type coverage. Off by default.
48
48
# unresolved-member-access = true
49
+
50
+
[indexing]
51
+
# How PHPantom discovers classes across the workspace.
52
+
# "composer" (default) - use Composer classmap, self-scan on fallback
# "none" - no proactive scanning, Composer classmap only
55
+
# strategy = "composer"
49
56
```
50
57
51
58
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.
52
59
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
+
53
90
## Editor Setup
54
91
55
92
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.
0 commit comments