This article mainly tells you how to set up and run the external tool OptiPNG, which is a png image compression tool, in phpstorm.
PhpStorm download address:
PhpStorm Mac version://m.sbmmt.com/xiazai/gongju/510
PhpStorm 18.2.1 Win version://m.sbmmt.com/xiazai/gongju/122
Although PhpStorm comes with many integrated utilities and tools, It's virtually impossible to include every tool in an IDE. By configuring an external tool we can create a shortcut to a tool that we can call from various menus or using keyboard shortcuts.
What if we want to run the OptiPNG tool to optimize our images and make them easy to run?
The specific implementation steps are as follows:
1. Create external tools through IDE settings
2. (Optional) Assign keyboard shortcuts to external tools
3. Use external tools
1. Create external tools through IDE settings
From settings (press Ctrl Alt S or Cmd on Mac OS X), find IDE settings | External tools.
In the opened window we can provide several basic options for the external tool:
Name - the name of the tool, which will also be displayed in the menu.
Description - Description of the tool that will be displayed in the PhpStorm status bar.
Group - External tool group. When creating multiple external tools, this setting can be conveniently used to group them into submenus.
If we want to view the output of the external tool in the console, we can keep the default Open Console checkbox enabled. We can choose to disable it and choose to only show external tool output when an error occurs.
We can also specify the display position of the tool. I'm using the default here, where external tools will be visible from the Tools menu, Editor menu, and context menus in various project views and search results. Please check the web help for complete instructions.
#The most important settings will be the program to be run, its parameters and the working directory. In the example above, OptiPNG will be run with the parameter -o4$FilePath$. Note that we can use macros in these settings, which can be used to reference the project name, current file path, path to the PHP executable, etc. The "Insert macro..." button will list all available macros and their values.
2. (Optional) Assign keyboard shortcuts to external tools
It is very useful to create keyboard shortcuts for external tools. From Settings (Ctrl Alt S or Cmd on Mac OS X), find IDE Settings | Keymap and find the tool we just created in the tree. Use the Add Keyboard Shortcut context menu to specify the shortcut. In the example below, we will assign the Alt I shortcut:
3. Create using an external tool
Once the tool is available, we can use it from the menu we specified. This can be the Tools menu or the context menu in the Project view:
We can also use the keyboard shortcut assigned in step 2: Press Alt I will run our external tool. Since we used the default settings from step 1, a console window will open showing the output of the external tool.
This article is an introduction to how to set up and run the external tool OptiPNG in PhpStorm. I hope it will be helpful to friends in need!
The above is the detailed content of How to setup and run external tool OptiPNG in PhpStorm. For more information, please follow other related articles on the PHP Chinese website!