Skip to content

Categories:

How use Composer with External Tools

Composer support in Zend Studio is quite simple. Sometimes users complain about lack of support for additional arguments e.g. for ‘install’ or ‘update’ commands. The new Zend Studio release includes support for running external programs inside your IDE. It’s called External Tools, and it’s well known to Eclipse users. It can be easily used to fill the gap between Composer support in Zend Studio and Composer command line capabilities. This simple tutorial will give you an idea on how to do it.

First of all we need a Composer based project. In my case I created a simple ZF2 project with Zend Studio and called it ‘project-zf2’. In the next step we need ‘composer.phar’. Check out these instructions for all the necessary information. Once created, move the file into the created project directory. Now we have all elements to play with Composer and External Tools.

External Tools configuration dialog can be started from the main menu (Run -> External Tools -> External Tools Configurations…), or from toolbar.

Toolbar

When the dialog window appears, double-click the Program element on the left menu. Now we need to input some basic parameters.

External Tools Configuration

  • Name – simple name to distinguish configurations (e.g. Update Composer)
  • Location – location of your PHP instance
  • Arguments:
    • $project_loc/composer.phar – specifies the location of the ‘composer.phar’ in project
    • update – Composer update command
    • –prefer-source – install packages from source when available
    • -d $project_loc – set project location as working directory
    • –no-ansi – disable ANSI output, not mandatory but without this parameter Console output can be polluted by strange characters
    • –no-progress – remove the progress display that can mess with some terminals or scripts which don’t handle backspace characters

All arguments:
$project_loc/composer.phar update –prefer-source -d $project_loc –no-ansi –no-progress

NOTE: Variable $project_loc will use the selected resource project location and will make this configuration independent from the project, but before every launch, a resource from the target project must be selected in the PHP Explorer or in the editor.

NOTE: Additional parameters must be placed after the command name, in this case after update.

Now, go to the Refresh tab and select Specific resources.

External Tools Configuration - Refresh Tab

In selection dialog choose vendor directory and composer.lock. These resources will be affected by Composer operation and after each execution these elements will be refreshed.

Edit Working Set Dialog

Go to Build tab and uncheck option Build before launch. This option has nothing to do with our case, but it can slow down command start.

External Tools Configuration - Build Tab

The rest of the tabs left with defaults parameters. Now your Composer update configuration is ready to be launched. Press Run (be sure that any resource from target project is selected). Command output will be displayed in Console view.

Console View

Now every Composer based project can be updated with Update Composer configuration! Recently used configurations can be easily accessed from toolbar drop down menu.

Start Configuration From Toolbar

External Tools allow you to configure and run programs, batch files, php scripts almost in the same way like in terminal. Every necessary command line tool can be configured and used inside Zend Studio (this tutorial can be applied also to PDT). Many useful PHP projects can be utilized in this way e.g. PhpMetrics. Everything in place and easy accessible. Enjoy!

The post How use Composer with External Tools appeared first on Zend Developer Zone.

|

Composer support in Zend Studio is quite simple. Sometimes users complain about lack of support for additional arguments e.g. for ‘install’ or ‘update’ commands. The new Zend Studio release includes support for running external programs inside your IDE. It’s called External Tools, and it’s well known to Eclipse users. It can be easily used to […]

The post How use Composer with External Tools appeared first on Zend Developer Zone.

}

Read more : How use Composer with External Tools

Posted in Uncategorized.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.