This plugin opens PHP files, Blade templates and Drupal's PHP files (.module, .theme and the
rest) in Orca with an editor backed by the
PHPantom language server. PHPantom understands
Laravel, Symfony, WordPress, Drupal, Yii 3, Tempest, PHPUnit and Pest, and detects each one from
the project, with nothing to switch on. The editor follows Orca's theme, font and save
behaviour, and adds:
- errors and warnings as you type, and completion that adds the
useline for a class - hover, signature help, inlay hints, go to definition (also into
vendor/), find references - quick fixes, code actions, formatting, rename within the file, colouring and an outline
orca plugin install noppu-labs/orca-phpantom
Orca shows what the plugin may do and prints an --approve flag; run the command again with it.
To try a branch, add it after an @, as in orca plugin install noppu-labs/orca-phpantom@<branch>.
- Orca 1.4.259 or newer, desktop app. The plugin does not run in the web client.
- Local workspaces. Files in SSH or other remote workspaces open with highlighting only.
- PHPantom 1.1.0 or newer. You don't have to install it yourself (see below).
phpon thePATHOrca starts with. Without it, PHPStan, PHPCS, PHPMD, Pint, PHP CS Fixer and phpcbf don't run, and nothing says why.
Nothing needs switching on. Open a file in the project and try these.
view('welcome')inroutes/web.phpgoes toresources/views/welcome.blade.php, andconfig('app.name')goes to thenameline inconfig/app.php.- Eloquent model properties such as
emailcomplete after$this->user->. In Blade,$loopinside@foreachis typed, so$loop->completesindex,firstandlast. <livewire:class-counter />goes toapp/Livewire/ClassCounter.phpfor a class component (made withmake:livewire --class).route('posts.index')for a Folio page goes toresources/views/pages/posts/index.blade.phpand is not flagged as an unknown route.
More in PHPantom's Laravel example.
- A service ID such as
'app.welcome_mailer'in a controller goes to its definition inconfig/services.php. A template name such as'demo/index.html.twig'goes to the Twig file, which opens in Orca's editor. - Route names complete inside
generateUrl(''), and an unknown one such as'app_demoo'is flagged.
More in PHPantom's Symfony example.
- Core's functions and classes come from
php-stubs/wordpress-stubs, so install it with Composer (composer require --dev php-stubs/wordpress-stubs). Hover on the result ofget_post()then showsWP_Post|null, and$wpdb->completes methods such asget_var()andprepare(). - A hook name in a theme's
functions.phpgoes to thedo_action()call that fires it.
More in PHPantom's WordPress example.
.moduleand.themefiles open in PHPantom's editor. A hook's parameters are typed from core's interfaces, so$route_match->inhook_help()completesgetRouteName().- A service ID such as
'acme.greeter'goes to its entry in the module's.services.yml, which opens in Orca's editor. A method called on an injected service goes to the service class.
More in PHPantom's Drupal example.
- In
config/common/routes.php, a route's action name goes to the controller method. - Route names complete inside
generate('')in a view and go to the route that names them. - An argument that no route has, such as
#[RouteArgument('slugg')], is flagged.
More in PHPantom's Yii example.
.view.phpviews open in PHPantom's editor, and a loop variable inside them is typed, so{{ $book-> }}completes the book'stitleandsummary().- A view path in a controller, such as
'/books.view.php', goes to the view file. - Route URIs complete inside
uri('').
More in PHPantom's Tempest example.
assertInstanceOf()narrows a nullable variable: after it, hover on$valueshowsDateTimeImmutablewithoutnull.- The name in
#[DataProvider('cases')]goes to thecases()method. - In a Pest test,
$thisis the test case thattests/Pest.phpbinds, so$this->completesget()and the other test helpers.
More in PHPantom's feature list.
PHPantom runs PHPStan, PHPCS, PHPMD and Mago itself when it finds them, and shows their results beside its own. PHPStan and PHPCS were tested through this plugin, with the gaps listed under Known gaps. PHPMD, Mago and the settings below are PHPantom's documented behaviour, not tested here.
| Tool | Runs when | Keys in .phpantom.toml |
|---|---|---|
| PHPStan | vendor/bin/phpstan (then PATH) exists and the project has a PHPStan config file or requires phpstan/phpstan or a Laravel PHPStan extension such as Larastan directly. A Laravel app with neither such an extension nor a config file is left alone |
[phpstan] command, memory-limit (default "1G"), timeout (default 60000) |
| PHPCS | vendor/bin/phpcs or phpcs on PATH exists |
[phpcs] command, standard (such as "PSR12"), timeout (default 30000) |
| PHPMD | PHPMD 3 is installed and the project has a PHPMD config file, or ruleset is set |
[phpmd] command, ruleset, timeout (default 30000) |
| Mago | mago.toml is at the project root: lint runs when it has a [linter] table, analyze when it has [analyzer] (on a Laravel project, only if mago.toml also wires up an extension) |
[mago] command, lint, analyze |
PHPantom documents that command = "" switches a tool off and command = "path/to/tool" uses
another binary, and that [diagnostics] workspace = true also checks unopened files in the
background. For example, to check against PSR-12 and switch PHPStan off:
[phpcs]
standard = "PSR12"
[phpstan]
command = ""All the keys are in PHPantom's configuration reference.
| Files | Opens in | Notes |
|---|---|---|
.php |
PHPantom's editor | Includes Tempest's .view.php views |
.blade.php |
PHPantom's Blade editor | |
.module, .install, .theme, .profile, .inc, .engine |
PHPantom's editor | Drupal's PHP files, opened here in every project. One that isn't PHP (a Debian .install, say) shows as plain text, and PHPCS, if present, reports Internal.NoCodeFound on it; pick Source in the view toggle to use Orca's editor |
.twig |
Orca's editor | Not supported yet, see issue #3 |
.yaml, .yml, .xml, .env |
Orca's editor | This plugin doesn't open them |
Outside a Drupal site, list Drupal's extensions without the dot (module, inc and so on) under
[indexing] extensions in .phpantom.toml so PHPantom also indexes the files you haven't opened.
The plugin uses the first phpantom_lsp it finds here:
- The
phpantomPathsetting, if you set one. - Your
PATH, then/opt/homebrew/bin,/usr/local/binand~/.cargo/bin(on Windows,%USERPROFILE%\.cargo\bin), in case Orca started without your shell'sPATH. - A copy it downloaded earlier.
- A fresh download of PHPantom 1.1.0 from GitHub, checked against its SHA-256, if
allowDownloadis on.
If phpantomPath doesn't point at a working phpantom_lsp, the plugin shows an error and stops
there. A copy on PATH older than 1.1.0 is skipped. Downloads go to the plugin's cache folder (on
macOS, ~/Library/Caches/noppu-labs.phpantom); hover the status bar item for the version and its source.
PHPantom: Show status(or a click on the status bar item) lists the binary, servers and open files.PHPantom: Restart language serversstops every PHPantom the plugin started, and open editors start them again within seconds. Run it after installing PHPantom or after a failed download.
phpantomPath: full path tophpantom_lsp. Leave it empty to usePATHor the download.allowDownload: whether the plugin may download PHPantom when none is installed. On by default.
With its [semantic-tokens] mode set to full, PHPantom colours classes, methods, functions,
properties, variables, attributes and Blade tokens. Its own default, contextual, marks only
parameters, template parameters, deprecated symbols and static member references.
When the plugin downloads PHPantom, it also writes a global PHPantom config that turns full
colouring on, unless you already have one. The file is ~/.config/phpantom_lsp/.phpantom.toml
(under $XDG_CONFIG_HOME if you set it, and %APPDATA%\phpantom_lsp\.phpantom.toml on Windows).
An existing file is never changed. Set mode = "contextual" there to go back.
If you installed PHPantom yourself, the plugin leaves the config to you, since other editors may
share it. A copy the plugin downloaded before version 0.2.1 gets no file either, because the plugin
reuses that copy instead of downloading again. In both cases, add these two lines to the global
file, or to .phpantom.toml at a project's root:
[semantic-tokens]
mode = "full"Autocomplete also opens .php files, so with both on
only one of them opens a PHP file, and which one is not confirmed yet (details).
To switch a file to PHPantom, use the view toggle at the top right of the editor tab, beside Source.
- Twig templates (issue #3), Symfony's YAML and
XML files, Drupal's
.ymlfiles and.envopen in Orca's editor without PHPantom's completion and navigation. Go to definition from PHP still opens a Twig template or a Drupal.services.ymlfile. - Code lenses and workspace symbol search are not shown.
- Livewire 4's single-file components (the
make:livewiredefault) don't resolve or complete in a<livewire:...>tag, a gap PHPantom 1.1.0 lists itself. Class components work. - In a Drupal site, opening a file under
web/core(say, by going toControllerBase) starts a second PHPantom forweb/core, which has its owncomposer.json. That server doesn't see the project'svendor/, so it flags Symfony classes such asRedirectResponseas unknown there. - Go to definition opens a very large file such as the 6 MB
wordpress-stubs.php, but its tab attached to PHPantom in only one of four tries, so hover and navigation in it may not work. - PHPStan and PHPCS results may not appear for a file opened while PHPantom is still starting. In our test that first open got none in 90 seconds; opening it again later showed them within 5 seconds.
- PHPStan and PHPCS results stay as they were after you edit. The plugin doesn't tell PHPantom when you save, and saving is what made PHPantom run them in a test outside Orca.
- PHPantom documents that most
.phpantom.tomlchanges apply within seconds, and that the PHP version and indexing strategy need a restart. We haven't checked this through the plugin, so if a change has no effect, runPHPantom: Restart language servers. - Rename works within the open file only. A rename or quick fix that would touch other files is refused.
- Inlay hints are off in Blade files, where PHPantom 1.1.0 adds stray ones such as
value:after{{. - The outline can come up empty for a very large class, such as one with 5,820 methods.
- A tab whose file the plugin can't identify gets highlighting only and tries again after you save.
- A
vendor/tab opened by go to definition gets highlighting only when you switch back to it with unsaved edits, or after Orca restarted the plugin. - Undo history and the cursor position reset when you switch back to a tab; unsaved text is kept.
- After a failed download the plugin waits two minutes to retry. Changing a setting or running
PHPantom: Restart language serversretries at once. - A tab that was already open when the plugin loaded may not attach until you open it again.
- A file changed on disk while its workspace is in the background updates only when you switch back.
- Errors and warnings appear a moment after a file opens. In a big project the first completions wait
for indexing, shown as
indexingin the status bar. - PHPantom lets go of a file about three minutes after you close its tab or switch away from it.
The test runs behind this README, with checklists for what needs a person at the keyboard, are in docs/smoke/v1-smoke.md and docs/smoke/frameworks-smoke.md.
Report bugs and request features in the issue tracker. Report security problems privately, as SECURITY.md describes. Changes come in as pull requests.
See docs/CONTRIBUTING.md for the local setup, the checks CI runs and how releases are cut. docs/ARCHITECTURE.md describes how the plugin works and its interfaces, docs/SECURITY_ASSESSMENT.md the risks it guards against, and docs/GOVERNANCE.md who maintains it.
- PHPantom does all the PHP and framework work.
- Parts of the language server plumbing, the binary lookup and the editor come from
Autocomplete by actus7 (MIT), see
THIRD_PARTY_NOTICES.md.
MIT. See LICENSE and THIRD_PARTY_NOTICES.md.