Supports Unix/Linux.
- Adds improved error detection from Phan to Visual Studio Code.
- Analyze code while you're typing.
- Optionally analyze code with syntax errors.
Note: This is just the VS Code extension that spawns Phan. Phan is implemented purely in PHP in its own repository, bugs in Phan analysis need to be implemented there and all issues should be reported there.
However, bugs in this VS code extension (crashes, etc) or related to the language server protocol should be reported in this extension's issue tracker
-
PHP 7.1+ must be installed. You can either add it to your PATH or set the
phan.executablePathsetting. -
Your Operating System must be Unix/Linux (Phan support depends on
pcntlmodule being installed, which is only available on those platforms)A future release may support Windows, but it won't be as fast.
-
The
php-astPECL extension must be installed and enabled. -
Depends on using a checkout of Phan with phan/phan#1144 installed
This extension hasn't been published yet. It can be installed locally with the following method:
npm install
npm run build
node node_modules/.bin/vsce packageThe generated VSIX file can be used locally with the steps from https://stackoverflow.com/a/38866913
This assumes you have already installed the dependencies.
Add these entries to your VSCode config (Open the menu at File > Preferences > Settings)
{
// Currently, this extension is limited to analyzing only a single folder.
// The config value must be the root of the project,
// and contain a .phan/config.php file with a Phan config for that project
// (including files to parse and analyze).
"phan.analyzedProjectDirectory": "/path/to/folder/to/analyze",
// Path to a php 7.1 binary with the php-ast PECL extension installed and enabled
"phan.phpExecutablePath": "/path/to/php7.1",
// Files which this should analyze
"phan.analyzedFileExtensions": ["php"]
}
After adding these entries, close and re-open Visual Studio Code in order for Phan to pick up the new settings.
Phan's capabilities are summarized in Phan's README
Optional, enabled by the setting phan.useFallbackParser
Clone whole repository and in root directory execute:
composer install
npm install
npm run build
code .The last command will open the folder in VS Code. Hit F5 to launch an Extension Development Host with the extension.
For working on the Phan language server, the easiest way is to override your config for the Phan language server installation from composer to point to the phan script within a git checkout of phan (Must set it up with composer install inside that checkout.).
First, checkout and setup a phan installation.
# Replace the placeholders /path/to/folder and phan_git_checkout with the folders you plan to use.
cd /path/to/folder/
git clone git@github.com:phan/phan phan_git_checkout
# Optionally, check out the branch being developed
# git checkout master
cd /path/to/folder/phan_git_checkout
composer installAnd then point to that phan installation:
{
"phan.phanScriptPath": "/path/to/folder/phan_git_checkout/phan"
}For guidance on how to set up a Phan project, please see phan/phan.
- Bump Phan version in composer.lock. Support new Phan plugin types. Include History in README.md
- Improve documentation. Mention that Visual Studio Code must be restarted in order to pick up any changes to this editor's phan settings.
- Reword README, rename extension to php-phan
This VS Code extension and many parts of the language server protocol implementation are based on PHP IntelliSense
This uses Phan

