Skip to content

Instantly share code, notes, and snippets.

@patrickallaert
Last active September 16, 2020 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickallaert/6a4ab48ad925d29fa6a02ab83ffb52e7 to your computer and use it in GitHub Desktop.
Save patrickallaert/6a4ab48ad925d29fa6a02ab83ffb52e7 to your computer and use it in GitHub Desktop.
Integrate Phan in PHPStom

HOWTO

  1. Install Phan in your project using Composer, it should create the script vendor/bin/phan, otherwise install it the way you want and hack the run-phan script.
  2. Install script run-phan (see at the bottom of this page) on your system (I decided to put it at /usr/local/bin/run-phan).
  3. In PHPStorm, go in Settings > Tools > External Tools, add a new tool and provide the parameters:
    • Program: /usr/local/bin/run-phan
    • Working directory: $ProjectFileDir$
    • Check "Open console for tool output"
    • Output filters: $FILE_PATH$:$LINE$
  4. You can now use it from Tools > External Tools > Phan (or assign it a shortcut)

#!/usr/bin/env bash
php -n -d zend_extension=opcache -d extension=ast vendor/bin/phan --color --no-progress-bar | sed -E 's|(\x1b\[[0-9;]*m)([a-zA-Z0-9\-_\./]+\x1b\[[0-9;]*m:\x1b\[[0-9;]*m[[:digit:]]+\x1b\[[0-9;]*m)|\1'"$(pwd)"'/\2|g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment