官术网_书友最值得收藏!

Customizing with PhpStorm

Sometimes thinking enough is not enough. Sometimes doing enough is not enough. The point is, despite learning so much, you still have a feeling that some more customization could have been possible. PhpStorm is at your disposal.

Getting ready

The best thing you can do is use PhpStorm for whatever PHP projects you take up. But therein the problem looms large. Executing PHP via a web server is OK, but what do you do about the use case when the script has to run in the background? What if your reporting manager wants you to do some socket programming? You need a command-line interpreter for PHP. Stunned silence? It's time to break that silence. Thank PhpStorm and integrate the command-line PHP interpreter with PhpStorm.

How to do it...

Just a small sequence of shortcuts is all that you need to invoke command-line PHP. There are actually two roads, that is, there is a bifurcation ahead. From the bifurcation, you will see two roads—on the left-hand side is the PhpStormish way, and on the right-hand side is the operating systemish way. The point worth noting is that both ways take you to the same destination. At the destination, you will attain your goal, which is to have the capacity to use PhpStorm for every PHP task.

You will be taken through the PhpStormish way first. This is easier, so you should try it first. This is termed as PhpStormish because PhpStorm lets you think that you are using PhpStorm itself to run your hard toiled PHP code. Perform the following steps:

  1. In order to run command-line PHP this way, you need to go to Settings | PHP, as shown in the next screenshot:
    How to do it...
  2. There is this interpreter dropdown. You need to add an interpreter. You can do that by selecting the PHP interpreter from the bin folder of the PHP installation.
  3. Once selected, you need to customize it by providing various parameters, such as a name and configuration options. On applying the changes, the PHP environment in PhpStorm will be powered by the PHP environment of your underlying operating system.
  4. This will enable you to test and run your PHP scripts using the default keyboard shortcut Ctrl + Shift + F10.

See also

Note

You can add more interpreters if you have multiple versions of PHP installed and select from those for execution.

That was easy to cook, right? Feeling happy? In this happiness, please don't forget that there was one more road, which was on the right-hand side, and which again took us to the same destination. PHP scripts or codes can be run on the terminal. Terminal—did this word strike bells in your mind? PhpStorm provides you a terminal (emulator) such that you do not have to switch back and forth between your beloved IDE (presumably) PhpStorm and the command-line terminal. You can again use this feature to execute command-line PHP scripts. All you have to do is type php your-php-file.php if you have the PHP classpath set, or else you need to add some extra letters to make it /path/to/installed-php/php your-php-file.php.

The following screenshot shows you how to run PHP through command line in PhpStorm:

See also
主站蜘蛛池模板: 安阳市| 长寿区| 方山县| 若尔盖县| 东兰县| 确山县| 奈曼旗| 湖南省| 九台市| 成武县| 石阡县| 诏安县| 玉树县| 祁门县| 彭山县| 垣曲县| 皮山县| 丰县| 大姚县| 穆棱市| 孝昌县| 凤翔县| 临江市| 肥城市| 琼结县| 股票| 嵊泗县| 洪江市| 丹凤县| 易门县| 福安市| 兴安县| 红安县| 杨浦区| 新绛县| 深水埗区| 繁峙县| 萨迦县| 通许县| 太保市| 莲花县|