Integrating Composer command line tool with PhpStorm

Built-in Command Line Tool support plugin provides autocompletion and documentation for any command line based tools. It needs just an xml commands description to support new tool. We plan to add automatic recognition of composer and other popular tools in future, but you can have it working today.

To get Composer dependency manager support in PhpStorm you need to open Settings | Command Line Tool Support and add custom configuration:

Set up alias you’d like to invoke and <php path> <composer path> in Tool Path, and then apply changes.

Then open xml description in editor by pressing and close settings. Copy and paste content of <framework> element from here. Or copy whole description, but then check alias and tool path of Composer in Settings. Voila!

Develop with pleasure!

This blog is permanently closed.

For up-to-date information please follow to corresponding WebStorm blog or PhpStorm blog.

 
This entry was posted in Cool Feature, PhpStorm, Tutorial and tagged , , , . Bookmark the permalink.

16 Responses to Integrating Composer command line tool with PhpStorm

  1. Sergey Belov says:

    Can I use it in IDEA or PhpStorm / WebStorm only?

  2. ragtek says:

    thx for this!

  3. Piotrek R. says:

    Why won’t you make it build in? :) And not call it a framework but just make it a place to add command tools?

    Even more – it’d be nice to have project-specific commands, e.g. I have bin/command file in my project which takes some arguments and can be run on a command line.

    I think what you did here has a huge potential but should reconsidered. :)

    • Piotrek R. says:

      I’m replying to my previous post. Command line tool in PhpStorm seems to be handling any command and running it in the app main directory, so in my case I can just enter bin/command and have it running.

    • Rafi B. says:

      It’s built-in. Maybe the phrase “Framework” confuses – you can execute any command line you want, describe it and attach parameters, you just need to edit the XML file. And automatic recognition is planned as written in this blog post.

  4. KingCrunch says:

    Must say, would like to see this as built-in supported framework instead, that may read the appropiate values from `help commandName` and such.

    Anyway

    - If you use Linux you can omit the $PhpExecutable$-variable, because the composer.phar contains a shebang-line and is therefore directly invokable.
    - If you use Linux, renamed `composer.phar` to `composer` and place it somewhere in $PATH you _must_ set a different alias, because otherwise the CLI-console use always `composer` found in $PATH.
    - You can append the CLI-option `–ansi` to make it look pretty by default :)

    • leneshka says:

      Thank you for useful answer.
      - On Linux you can change Tool path from Settings to simply composer.phar.
      - Plugin first tries to resolve alias, so it would be changed to the tool path anyway.
      - It can be done adding ‘-ansi’ to every command name, i.e. replacing ” to ‘ -ansi’

    • Rafi B. says:

      It shouldn’t be “instead”. It’s built-in support for command line tools, as described by XML files. You can make phpStorm recognize any command line tool by editing a simple XML. And like mentioned in this blog post, future versions will automatically recognize popular tools. It already supports “Zend Framework” and “Symfony” command line tools.

  5. ijin says:

    thank you! that’s great!

  6. Ondra says:

    Thank you, great work!

  7. Rafi B. says:

    This is indeed a great feature PhpStorm has had for a long time. However, I find myself using the “External Tools” much more often, it has great features:
    * Appears in main-menu/editor/project views/search results, just right-click! This means you have context-aware macros you can use. (Like $FilePath$ and $SelectedText$ even! That’s freakin’ awesome indeed)
    * Has output-aware regular expression filters!
    * Has many useful macros
    * Can be grouped into sub-menus
    * Can synchronize files after execution
    * Can set working directory

    About “Command Line Tool Support“, a few questions:
    1) Is there any schema definition somewhere or documentation for the XML definition file?
    2) Please consider renaming “Framework” in pop-ups to “Tool”. One might be confused with the “Framework Integration” feature. And as the name “Command Line Tool Support” suggests, these are tools, not frameworks. Though this can blown into a whole philosophic debate..

    • Henry Garcia says:

      @Rafi B +1 on the External tools. I just set up that way and simplest way to go.

    • leneshka says:

      1) Schema lays in /.WebIde50/config/commandlinetools/schemas/frameworkDescriptionVersion1.1.2.xsd
      Also there is tutorial here.
      2) Currently renaming. Should be available in 6th EAP.

  8. Torben Hansen says:

    Here is a simple configuration file for TYPO3 Flow: https://github.com/derhansen/typo3-flow-phpstorm-cl-xml

Comments are closed.