Home  >  Article  >  Development Tools  >  How to enable command line tools in PhpStorm

How to enable command line tools in PhpStorm

藏色散人
藏色散人Original
2018-11-10 11:00:0120863browse

This article mainly introduces how to use the command line tools in phpstorm.

PhpStorm download address:

PhpStorm Mac version: http://www.php.cn/xiazai/gongju/510

PhpStorm 18.2.1 Win version: http://www.php.cn/xiazai/gongju/122

PhpStorm uses command line tools, we can call commands directly from the IDE ! Before we use any command line tool, we have to enable it in the settings.

The steps involved are as follows:

  • Use the command line tool console

  • Enable the command line tool

  • Enable a well-known command line tool

  • Enable a custom command line tool

  • Define the command line tool to add the auto-complete function

Use the command line tool console

We can use Tools | Run Command... to bring up the command line tool Run Command menu Or use Ctrl Shift X (Cmd Shift X on Mac).

The command line tool supports automatic completion of several known tools. We need to add and enable the tools we want to use through settings. For example, after adding Composer, we get autocomplete on all composer commands (note that in the screenshot below, the default alias "c" has been changed to "composer"):

How to enable command line tools in PhpStorm

We can also add other tools. The following is an example using the Symfony tool, alias s.
How to enable command line tools in PhpStorm

Enable command line tool

Enable a well-known command line tool

PhpStorm supports various well-known tools:

  • Composer

  • ##Zend Framework (version 1 and 2)

  • Symfony

  • Symfony console-based tools (Doctrine, Laravel)

  • Drush (for Drupal)

In addition, custom command line tools are also supported.

Command line tools must be enabled in settings. We can do this globally (for all projects) or per project.

1. From Project Settings | Command Line Tool Support, add a new tool using the icon on the toolbar

2. Select a supported tool and Specifies tool visibility. This can apply only to the current project or globally (applies to all projects).

In this tutorial, we will select Composer as the tool and specify Project as Visibility.

3. In the next step, some additional settings must be provided. Typically this will be at least the path to the command line tool selected in the previous step.

For this example, specify the path to composer.phar. If Composer is already used in the project, PhpStorm should fill in this path automatically.

4. Click OK, and note that the tool will be added to the list of command line tools. We can see the alias (which will be used to call the tool) and the full path to the tool. We can change the alias if we want.

In our example, Composer added the alias "c".

5. Close settings.

How to enable command line tools in PhpStorm

Enable custom command line tools

To enable custom tools, you can follow Similar workflow.

1. From Project Settings | Command Line Tool Support, use the icon on the toolbar to add a new tool

2. Select a custom tool. The tool can be enabled only for the current project or globally (for all projects).

3. In the next step, some additional settings must be provided: tool name, full path to the tool, alias and description:

How to enable command line tools in PhpStorm

4. Click OK, and note that the tool is added to the list of command line tools. We can see the alias (which will be used to call the tool) and the full path to the tool.

5. Alternatively, we can provide the IDE with auto-complete information.

6. Close settings.

Add autocomplete for custom command line tools

PhpStorm cannot determine autocomplete for every custom tool we add automatically. But we can create our own definitions.

1. From Project Settings | Command Line Tool Support, select the tool for creating autocomplete information and click the "Open definition in browser" button to generate the boilerplate command Line tool description:

How to enable command line tools in PhpStorm

2. The editor will open an XML file where information about the custom tool can be added. We can now define commands, parameters and help information for custom command line tools. You can also check the Command Line Tools - Custom Tools command definition.

3. After saving the XML file containing the description, PhpStorm will recognize the command and provide autocomplete for our custom command line tool.

How to enable command line tools in PhpStorm

This article is about the steps of using the command line tool in PhpStorm. I hope it will be helpful to friends in need!

The above is the detailed content of How to enable command line tools in PhpStorm. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn