Configuration Reference¶
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.toml¶
PHPantom supports an optional per-project configuration file. To generate a starter config file:
On an interactive terminal, this walks through the settings projects
customize most often (PHP version, indexing strategy, a few diagnostic
toggles, semantic token mode) and writes only the answers that differ
from PHPantom's defaults. Press Enter to accept a default and skip a
question. Run phpantom_lsp init --yes (or pipe stdin, e.g. in a
script) to skip the prompts and write a minimal .phpantom.toml with
just a JSON schema directive instead.
Editors with TOML schema support (Zed, VS Code + Even Better TOML,
Neovim) provide autocomplete and hover documentation for every option
via the schema. Only add settings you want to override -- when absent,
all settings use their defaults. Settings that need a list or a table
(indexing.exclude, [[diagnostics.ignore]], per-tool command
overrides) aren't part of the wizard; add those by hand.
Global config¶
Settings you want in every project belong in the global config rather
than in a .phpantom.toml per repository:
It lives at $XDG_CONFIG_HOME/phpantom_lsp/.phpantom.toml (typically
~/.config/phpantom_lsp/.phpantom.toml on Linux and macOS alike, and
%APPDATA%\phpantom_lsp\.phpantom.toml on Windows), takes exactly the
same keys as a project config, and is read first. macOS follows the XDG
path rather than ~/Library/Application Support, which is where a
command-line tool's config is expected to be, and keeps the path the
same across a machine you use both platforms on. A project config is
then merged over it key by key, not wholesale, so a project only has to
spell out the settings where it differs from your defaults: with
workspace = true and extra-arguments = true set globally, a project
that sets only workspace = false still gets extra-arguments.
Both the global config and a project's own .phpantom.toml are
watched, and most settings take effect within a couple of seconds of
saving either file. The exceptions are settings that shape the initial
workspace scan, such as the PHP version and indexing strategy below --
those still need a restart to fully apply.
A key PHPantom does not know, such as a typo or a setting from a newer
release, is ignored with a warning that names the key and the file it
is in. The editor shows it when the config loads, and analyze, fix,
format, and move print it on stderr. The rest of the config still
applies.
The full schema is at config-schema.json.
Compatibility¶
From 1.0, the configuration format is stable: a key that works in one
1.x release keeps working, with the same meaning, in every later 1.x
release. New keys and sections can be added, and a new key's default is
chosen so that a config written for an earlier release behaves the same.
The same promise covers the diagnostic identifiers
that [[diagnostics.ignore]] and @phpantom-ignore match on. The
wording of a diagnostic's message is not covered and can be improved in
any release, so prefer identifier over message in an ignore rule
that has to keep working.
Every section and key is spelled in kebab-case. A name that was spelled differently before 1.0 is still read under its old spelling, with a warning that names the new one, so an older config keeps working.
The schema a generated .phpantom.toml points at is served from the
main branch, so it always describes the newest release. An editor may
therefore offer a key your installed version does not know yet. Such a
key is reported as unknown; check the changelog for the
release that added it.
[php]¶
| Key | Type | Default | Description |
|---|---|---|---|
version |
string | Inferred from composer.json | Override the detected PHP version (e.g. "8.3"). |
PHPantom understands PHP syntax up to 8.5. The version, taken from the
php requirement in composer.json when this key is unset and 8.5
when neither says, decides which built-in functions, classes, and
constants exist, and which version-specific diagnostics and code
actions apply.
[diagnostics]¶
| Key | Type | Default | Description |
|---|---|---|---|
enabled |
bool | true |
Show diagnostics in the editor at all. Set to false to report nothing: no native diagnostics (syntax errors included), no external tool runs, and no workspace pass. Every other key in this section is then moot. analyze ignores it. |
unresolved-member-access |
bool | false |
Report ->, ?->, :: where the subject is mixed or its type could not be worked out. Useful for type coverage, noisy on untyped codebases. |
extra-arguments |
bool | false |
Report calls that pass more arguments than the function accepts. |
magic-properties |
bool | false |
Report unknown property access on classes with __get when virtual properties are defined. Matches PHPStan's reportMagicProperties. |
partial-union-members |
bool | false |
Report a member access on a union when only some of its classes declare the member. Matches PHPStan's checkUnionTypes. |
possibly-empty-mismatches |
bool | false |
Report a type mismatch on an argument, return value or property assignment when the only members that fail are null or false, such as a string\|false passed to a string parameter. Matches PHPStan's checkUnionTypes and checkNullables. |
partial-union-mismatches |
bool | true |
Report a type mismatch on an argument, return value or property assignment when some members of the value's union fit, such as an array\|string passed to a string parameter. Set to false to only report values no member of which fits, which also leaves out what possibly-empty-mismatches covers. |
docblock-type-mismatches |
bool | true |
Check arguments, return values and property assignments against the types docblocks declare. Set to false to only report values that break the native type, for legacy code whose docblocks have drifted from what the code does. |
unhandled-exceptions |
bool | false |
Report a throw, or a call whose callee declares @throws, when the exception is neither caught nor covered by a @throws tag of the function or method it is in. Offers an "Add @throws" quick fix. Matches PhpStorm's "Unhandled exception" inspection and PHPStan's checked exceptions. |
unchecked-exceptions |
string[] | ["Error", "LogicException", "RuntimeException"] |
Exception classes, fully qualified, that unhandled-exceptions does not report, along with every class that extends them. The default is the list PhpStorm treats as unchecked. |
unused-parameters |
bool | false |
Dim a parameter a function, closure, or method never reads, when it comes after the last one the body does read. Methods whose signature an interface, a parent class, or a possible override dictates are left alone, and so is a parameter whose name starts with $_. |
workspace |
bool | false |
Compute diagnostics for the whole workspace in the background after startup, so problems appear for files you have not opened. Costs a project-wide sweep every session. Requires the default full indexing strategy. |
workspace-external |
bool | true |
Run configured external tools (PHPStan, PHPCS, PHPMD, Mago) once over the whole project after workspace diagnostics finish. Only takes effect when workspace is enabled. |
[[diagnostics.ignore]]¶
Rules that suppress matching diagnostics, similar to PHPStan's
ignoreErrors. Each rule may constrain by message (regex), path
(glob relative to workspace root), and/or identifier (diagnostic
code). A diagnostic is suppressed when it matches every constraint
present on a rule; omitted constraints match anything.
[[diagnostics.ignore]]
path = "tests/**"
[[diagnostics.ignore]]
identifier = "deprecated_usage"
message = "^Function some_legacy_helper\\(\\) is deprecated"
The identifiers are listed in the Diagnostics Reference.
Inline suppression¶
To silence one diagnostic where it happens rather than project-wide, put
an @phpantom-ignore comment on the same line, or on its own line just
above:
$legacy->magicCall(); // @phpantom-ignore unknown_member
// @phpantom-ignore unused_variable, deprecated_usage
$unused = some_legacy_helper();
/* @phpantom-ignore */
$everything->on($this, 'line');
List one or more identifiers, separated by commas, to suppress only
those. Leave them out to suppress every diagnostic on the line. A
comment applies to the line a diagnostic starts on, and it covers
diagnostics from external tools (PHPStan, PHPCS, PHPMD, Mago) shown in
the editor as well as PHPantom's own. analyze honours it too.
[indexing]¶
| Key | Type | Default | Description |
|---|---|---|---|
strategy |
string | "full" |
Class discovery strategy: "full", "composer", "self", or "none". See Indexing Strategy below. |
exclude |
string[] | [] |
Paths the workspace scanners skip, in gitignore syntax relative to the workspace root: a bare name matches at any depth, a pattern containing / anchors to the root, a trailing / restricts to directories, and a leading ! re-includes. Applies to background discovery, to the classes Composer's autoload maps list, and to the directories analyze walks. A file you open in the editor, or name outright on the analyze command line, is always served. A leading ! only undoes your own patterns, so use include to bring back a hidden, gitignored, or built-in skipped path. |
extensions |
string[] | [] |
Extra file extensions (without the dot) treated as PHP source during workspace discovery, e.g. ["module", "inc", "theme"]. .php is always included, and a Drupal site gets Drupal's extensions automatically. |
include |
string[] | [] |
Files and directories to index even though the workspace scan skips them, relative to the workspace root unless absolute. See Extra Include Paths below. |
[indexing]
exclude = ["generated", "web/sites/default/files"]
extensions = ["module", "install", "theme"]
Extra Include Paths¶
The workspace scan respects .gitignore and skips hidden files and
directories, which is what keeps it out of node_modules/, build output,
and editor metadata. It also skips the _ide_helper.php and
_ide_helper_models.php files laravel-ide-helper generates, since
PHPantom resolves facades and models without them. That can hide PHP a
project genuinely depends on: code in a dotted directory, or a generated
file that is gitignored because it is a build artefact, yet is the only
declaration of the functions the project calls.
Listing a path under include indexes it anyway, whichever of those
rules skipped it. A named file is read directly. A named directory is
walked recursively, including hidden and gitignored entries inside it,
for the same extensions the workspace scan uses, and exclude patterns
still prune what is below it. Entries that do not exist are ignored.
Relative paths resolve against the workspace root.
Castor task files are an example, a
.castor/ directory of tasks and a gitignored .castor.stub.php
describing Castor's own functions:
Where the path lives decides how it is treated:
- Inside the workspace it is your own code, the same as anything the
scan found.
analyzereports on it, and rename and find-references cover it. - Outside the workspace it is a library, the same as
vendor/. Its symbols complete and resolve, but it is never analysed or edited. Use this for shared code that lives elsewhere on disk.
Included paths fill gaps. They are indexed after everything else, so a class or function the project or its dependencies already declare keeps that declaration, and an included file cannot override it. Adding an entry while the editor is running indexes it straight away; removing one takes effect on the next restart.
The other folders of a multi-root workspace need no entry here. Every folder the editor lists beside the one PHPantom is rooted in is indexed the same way as an outside path, as a library, so a project resolves the classes of a shared library open in the same window. A folder that sits inside another one, or inside the project, is already covered and is not indexed twice. Adding a folder to the workspace indexes it straight away, and removing one drops its symbols straight away.
[stubs]¶
| Key | Type | Default | Description |
|---|---|---|---|
paths |
string[] | [] |
Stub files and directories whose declarations win over every other declaration of the same name, relative to the workspace root unless absolute. |
A class, function, or constant a stub path declares is what that name means, whatever the project, its dependencies, or PHP's own built-in stubs declare under it. That makes a stub path the place for hand-written stubs of a PHP extension, type information for code that only exists at runtime, or a corrected signature for a function whose built-in declaration you disagree with.
Paths are read the way include paths are: a named file directly, a
named directory recursively with hidden and gitignored entries included,
and exclude patterns still pruning what is below it. Entries that do
not exist are ignored. Where two stub paths declare the same name, the
one listed first wins. A directory holding a checkout of
phpstorm-stubs is read
from its PhpStormStubsMap.php, so only the files the map names count.
Stub packages installed with Composer need no entry here. A package
named jetbrains/phpstorm-stubs, php-stubs/*, or *-stubs (such as
php-stubs/wordpress-stubs or php-stubs/woocommerce-stubs), or one
whose type is php-stubs or phpstorm-stubs, is used as a stub path
automatically, ranked below the paths listed here. Installing,
updating, or removing one takes effect straight away.
phpstan/php-8-stubs is the exception: PHPantom's own stubs of PHP's
functions are more precise, so it stays ordinary vendor code.
A stub file is never analysed, renamed into, or searched for references, whether it sits inside the workspace or not, and go-to-definition lands in it. Editing, adding, or removing a stub path takes effect straight away, as does a change to a stub file inside the workspace. A stub directory outside the workspace is not watched, so an edit inside it is seen after a restart.
Which key do I want?¶
| You want | Key |
|---|---|
| PHPantom to skip a path | [indexing] exclude |
| PHP the workspace scan skips (hidden, gitignored, or outside the workspace) to resolve where nothing else declares the name | [indexing] include |
| A declaration to win over every other declaration of the same name | [stubs] paths |
The difference between include and [stubs] only shows when
something else declares the same name: an included path fills gaps, a
stub path overrides. So a generated stub such as Castor's
.castor.stub.php works under either key, but belongs under [stubs],
which also keeps analyze from reporting on it. Listing the
_ide_helper.php laravel-ide-helper generates under [stubs] is how you
deliberately make its stand-in classes win, where include only lets
them fill gaps.
[semantic-tokens]¶
PHPantom defaults to contextual semantic tokens so editor syntax
highlighting remains in charge of ordinary PHP syntax.
| Key | Type | Default | Description |
|---|---|---|---|
mode |
string | "contextual" |
Semantic token mode: "contextual", "full", or "off". |
| Mode | Behaviour |
|---|---|
"contextual" |
Emit only context-sensitive tokens that complement Tree-sitter/TextMate highlighting, such as parameters, PHPDoc template parameters, deprecated references, and static member accesses. |
"full" |
Emit the complete semantic token stream, including ordinary classes, variables, functions, methods, properties, comments, keywords, attributes, and Blade tokens. |
"off" |
Return no semantic tokens. |
[inlay-hints]¶
| Key | Type | Default | Description |
|---|---|---|---|
parameter-names |
bool | true |
Parameter names before the arguments of a call, such as needle:, along with the & of a by-reference parameter. |
closure-types |
bool | true |
Inferred parameter and return types on closures and arrow functions that do not declare them. |
Your editor can switch these off too, see Editor-supplied inlay hint toggles. Editing this section takes effect in open files without a restart.
[formatting]¶
| Key | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | unset | Whether formatting is enabled at all. Unset or true: format with the strategy below. false: turn formatting off, built-in formatter included. |
pint |
string | unset | Command or path for Laravel Pint. Unset: auto-detect from require-dev. "": disable. |
pint-blade |
boolean | unset | Whether .blade.php files are formatted by Pint's Pint/laravel_blade rule. Unset: follow the workspace pint.json. true: send them to Pint with --blade. false: never. |
blade-formatter |
string | unset | Command or path for blade-formatter, used for .blade.php files. Unset: use it when the project does (see below). "": never. Any other value: always, even over Pint. |
blade-php |
boolean | unset | Whether the built-in Blade formatter also formats the PHP a template carries. Unset: leave every fragment as written. true: format it. No effect on a project whose Blade files go to Pint or blade-formatter. |
php-cs-fixer |
string | unset | Command or path for php-cs-fixer. Unset: auto-detect from require-dev. "": disable. |
phpcbf |
string | unset | Command or path for phpcbf. Unset: auto-detect from require-dev. "": disable. |
timeout |
integer | 10000 |
Max runtime in milliseconds per external formatting tool. |
[phpstan]¶
| Key | Type | Default | Description |
|---|---|---|---|
command |
string | unset | Command or path for PHPStan. Unset: auto-detect via vendor/bin/phpstan (only when the project has a PHPStan config file or composer.json requires phpstan/phpstan, or a Laravel-aware PHPStan extension such as larastan/larastan or calebdw/phpstan-laravel, directly) then $PATH. A Laravel application with neither such an extension nor a config file is left alone entirely, since plain PHPStan misreads the framework. "": disable. |
memory-limit |
string | "1G" |
Memory limit passed to PHPStan via --memory-limit. |
timeout |
integer | 60000 |
Max runtime in milliseconds before PHPStan is killed. |
[phpcs]¶
| Key | Type | Default | Description |
|---|---|---|---|
command |
string | unset | Command or path for PHPCS. Unset: auto-detect via vendor/bin/phpcs then $PATH. "": disable. |
standard |
string | unset | Coding standard to enforce (e.g. "PSR12"). phpcbf fixes against the same standard. Unset: PHPCS uses its own default detection. |
timeout |
integer | 30000 |
Max runtime in milliseconds before PHPCS is killed. |
[phpmd]¶
PHPMD 3 is required. Earlier versions have a different command line.
| Key | Type | Default | Description |
|---|---|---|---|
command |
string | unset | Command or path for PHPMD. Unset: auto-detect via vendor/bin/phpmd then $PATH, only when the project has a PHPMD config file (phpmd.yml, phpmd.xml, .phpmd.yml, phpmd.xml.dist, and the other names PHPMD looks for) or ruleset is set. "": disable. |
ruleset |
string | unset | Ruleset name or file passed via --ruleset (e.g. "cleancode"). Unset: PHPMD uses the config file it finds in the project root. |
timeout |
integer | 30000 |
Max runtime in milliseconds before PHPMD is killed. |
[mago]¶
Mago is only activated when mago.toml exists at the workspace root.
| Key | Type | Default | Description |
|---|---|---|---|
command |
string | unset | Command or path for Mago. Unset: auto-detect via vendor/bin/mago (only when composer.json requires carthage-software/mago directly) then $PATH. "": disable. |
lint |
bool | unset | Proxy mago lint diagnostics. Unset: only when mago.toml has a [linter] table. |
analyze |
bool | unset | Proxy mago analyze diagnostics. Unset: only when mago.toml has an [analyzer] table, and on Laravel only when it also wires up an extension. |
lint-timeout |
integer | 30000 |
Max runtime in milliseconds before mago lint is killed. |
analyze-timeout |
integer | 60000 |
Max runtime in milliseconds before mago analyze is killed. |
Which of Mago's two diagnostic commands run follows the workspace mago.toml, since a project that uses Mago for one thing rarely wants the others. A mago.toml holding a [formatter] table and nothing else belongs to a project that formats with Mago and checks its code with something else, so neither mago lint nor mago analyze is proxied for it.
On a Laravel project, mago analyze additionally needs the mago.toml to wire up an extension, either an enabled [extension-hosts.*] entry or a namespaced plugin such as plugins = ["acme/laravel"]. Mago's analyser has no built-in Laravel support, so without one it cannot see through Eloquent or the facades and reports correct code in bulk. Mago's own plugins (stdlib, psl, flow-php, psr-container) do not count, since none of them supplies that knowledge. mago lint is unaffected, as its linter does have a Laravel integration.
Set lint or analyze explicitly to override all of this in either direction.
[laravel]¶
[laravel.schema]¶
| Key | Type | Default | Description |
|---|---|---|---|
enabled |
bool | true |
Enable Laravel schema dump scanning for Eloquent model property inference. |
paths |
string[] | ["database/schema"] |
Schema dump files or directories to scan, relative to the workspace root. |
[laravel.migrations]¶
| Key | Type | Default | Description |
|---|---|---|---|
enabled |
bool | true |
Enable Laravel migration scanning for Eloquent model property inference. |
paths |
string[] | unset | Migration files or directories to scan. Defaults to non-vendor database/migrations directories. |
The file is optional. Unknown keys are silently ignored, so the file is forward-compatible.
Editor-supplied file filters¶
Your editor already knows which folders it hides and which extensions it opens as PHP. PHPantom accepts the same two [indexing] lists from the editor over LSP, so that knowledge does not have to be mirrored into .phpantom.toml by hand:
The server reads that shape from initializationOptions at startup and from workspace/didChangeConfiguration when you change your settings mid-session. It is also accepted namespaced under a phpantom key, which is how a client that pushes its whole settings tree sends it.
A notification that carries no indexing block leaves the filters as they are, since clients re-push their settings for reasons of their own. To clear the filters, send an indexing block with empty lists rather than omitting it.
A change made mid-session is reconciled against the index built under the previous filters, so neither direction needs a restart: classes under a path you just excluded leave the index, and files a removed exclude or an added extension brings back into scope are picked up by a fresh workspace scan a moment later. That scan is debounced, so a burst of settings changes costs one walk rather than one each. Editing .phpantom.toml is reconciled the same way. A file you have open in the editor is always served, whatever the filters say about it.
The values mean exactly what the [indexing] keys of the same name mean: exclude is gitignore syntax relative to the workspace root, and extensions are extra file extensions (without the dot) treated as PHP source. Only those two keys are read; the indexing strategy stays a project decision.
Editor settings and .phpantom.toml are two layers of one filter set rather than one overriding the other, so:
- Both lists apply. A path either side excludes is excluded, and an extension either side names is indexed.
- Changing one never drops the other. Reloading
.phpantom.tomlkeeps what the editor sent, and a settings change keeps what the file says. - A
!re-include in.phpantom.tomlstill wins over an exclude the editor sent, following the usual gitignore rule that the last matching pattern decides. This is how a project keeps one generated file indexed that its contributors happen to hide in their editors.
The interface is deliberately generic (a list of globs and a list of extensions, never an editor's own setting names), so any client can translate its native settings into it. See Editor Setup for what each editor does with it.
Editor-supplied stubs¶
An editor extension that ships stubs alongside the server (phpstorm-stubs as plain files, for instance) passes their directory the same way:
It is read from initializationOptions and workspace/didChangeConfiguration, also under a phpantom key, and a notification without a stubs block leaves it as it is. The directory is treated exactly like a [stubs] path listed after the project's own, so the project's choices win where both declare a name. This is meant for extensions, not users: to add stubs yourself, use [stubs] paths.
Editor-supplied inlay hint toggles¶
An editor extension can offer its own switches for the [inlay-hints] kinds and pass them the same way:
It is read from initializationOptions and workspace/didChangeConfiguration, also under a phpantom key, and a notification without an inlayHints block leaves the toggles as they are. A key left out has no opinion. When a toggle changes, PHPantom asks the editor to re-request the hints of open files, so the change shows at once.
A kind is shown only when neither .phpantom.toml nor the editor turns it off. Editors send their default true along with every other setting, so an editor's true never brings back a kind the config file switched off.
Code Formatting¶
PHPantom ships a built-in PHP formatter (mago-formatter) that works out of the box, so textDocument/formatting requests are answered without any setup. The formatter is chosen per project in this order:
- Explicit config wins. A tool path set under
[formatting]in.phpantom.toml(pint,php-cs-fixer, orphpcbf) is always used. Setting a tool to""disables it. - Composer
require-devwins over the built-in formatter. Ifcomposer.jsonlistslaravel/pint,friendsofphp/php-cs-fixer, orsquizlabs/php_codesnifferinrequire-dev, PHPantom resolves the binary through Composer's bin-dir and runs it as a subprocess. Aphpcs.xml,.phpcs.xml,phpcs.xml.dist, or.phpcs.xml.distfile at the workspace root certifies phpcbf the same way, so a project that only pullssquizlabs/php_codesnifferin transitively (e.g. throughslevomat/coding-standard) is still detected. These tools discover their own project config (pint.json,.php-cs-fixer.php,.phpcs.xml, etc.) as they normally would. - Otherwise, the built-in formatter is used. This includes projects that set every external tool to
"".
To turn formatting off entirely, set enabled = false under [formatting].
Formatting a selection (textDocument/rangeFormatting) works with every one of these. None of them can format part of a file, so PHPantom formats the whole file and applies only the changes on the selected lines. A change that runs past the edge of the selection is applied whole, so the file never ends up half-formatted mid-statement, and lines the formatter moved (sorted imports, for example) are moved as a unit rather than dropped or duplicated.
Blade templates are resolved on their own, since of the PHP formatters only Pint knows how to format one. A .blade.php file goes to Pint when the project's pint.json turns the Pint/laravel_blade rule on (or pint-blade = true asks for it, which also passes --blade). Otherwise it goes to blade-formatter when the project uses it, meaning package.json lists blade-formatter, the workspace root has a .bladeformatterrc.json or .bladeformatterrc, and npm install has put it in node_modules/.bin. It runs from the workspace root so it reads that config file, and templates listed in .bladeignore are left alone. That way saving a template formats it exactly as the project's own blade-formatter run would. Everything else goes to PHPantom's built-in Blade formatter. The built-in formatter reindents the template without changing the content of any line: indentation follows the nesting of directives, HTML and component tags, multi-line attribute lists and values, and brackets left open at the end of a line, using the editor's tab size and spaces-or-tabs setting. The bodies of <script>, <style>, and @php blocks are moved as a unit and keep their own layout; <pre>, <textarea>, and @verbatim contents are left exactly as written, as is anything between {{-- blade-formatter-disable --}} and {{-- blade-formatter-enable --}}. Templates whose indentation is output are never touched: Envoy task files, Markdown mail templates (under resources/views/mail, resources/views/emails, or vendor/mail, or using <x-mail:: components), and Laravel Boost guidelines.
Setting blade-php = true adds a pass that formats the PHP a template carries through the same built-in PHP formatter (and the same mago.toml settings) a .php file gets: @php bodies and <?php islands as statement lists, echoes, <?= islands, and directive arguments as expressions, along with the spacing that is Blade's own rather than PHP's, so @if($a&&$b) becomes @if ($a && $b) and {{$x}} becomes {{ $x }}. It is opt-in because it changes the content of a line, which the reindenter on its own never does. A fragment written across several lines is formatted where it stands, wrapped for the width the column it sits at actually leaves it. How many lines a fragment takes stays the author's, though: an array broken over several lines is respaced without being joined onto one, and a long line is respaced without being broken up. A fragment the formatter cannot parse is left exactly as written and the rest of the template still formats, and the pass stays out of everything the reindenter leaves alone, plus Alpine and Livewire attribute values, which are JavaScript.
The built-in formatter defaults to the PER-CS 2.0 style. If a mago.toml is present at the workspace root, its [formatter] table is honoured instead, so PHPantom formats with the same preset and settings your project already uses with the Mago CLI:
For the full list of [formatter] options (presets, brace placement, blank-line handling, casing, and the rest), refer to the upstream Mago documentation: Formatter configuration reference.
Indexing Strategy¶
By default, PHPantom builds a full workspace index: it discovers PHP files, then background-parses user files to populate symbol maps and the reference candidate index. This gives complete cross-file references, implementation lookup, and workspace-wide navigation without per-feature scanning.
The strategy setting controls this behaviour:
| Strategy | Behaviour |
|---|---|
"full" (default) |
Scan PHP files, then background-parse user files to populate symbol and reference indexes. |
"composer" |
Use Composer's classmap when available, self-scan to fill gaps. Results stay closer to 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 "composer" or "none" only if you want a lighter or more Composer-constrained index.
Troubleshooting¶
Classes from other files are not found¶
PHPantom resolves cross-file classes through the full workspace index by default. If a class exists in your project but PHPantom reports it as unknown, the most common causes are:
-
The file is excluded from the workspace walk. Check ignored directories and
.gitignorerules. If you explicitly setstrategy = "composer"or"none", classes outside Composer's autoload rules may be skipped. -
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.