在PhpStorm中使用一个快捷方式上传多个文件 [英] Upload multiple files with one shortcut in PhpStorm

查看:54
本文介绍了在PhpStorm中使用一个快捷方式上传多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在PhpStorm中使用单个快捷方式上传选择的文件?

理想情况下,它使用PhpStorm部署机制-但欢迎提供所有答案.例如制作bash文件,然后将scp文件覆盖(然后使用PhpStorm执行).

我正在寻找一种方法,只需按以下命令即可: CMD + OPT + CTRL + J-然后上传所有这些标记的文件.

我的项目具有以下所示的结构.我已经用(x)标记了我希望能够上传的文件:

 项目|-子文件夹|-子文件夹|-资产||-CSS(x)||-js(x)||-管理员(x)||-img||-foo.php|-bar.php|-style.css(x)|-bundle.js(x)|-other.php|-other-1.php 


Attempt1

我已经尝试过:将更改的文件自动上传到默认服务器"==始终|在显式保存..." -这非常神奇.但是,如果设置不正确-则可能造成混乱.

解决方案

好的.这就是我做的.最后!!!我多年来一直在寻找它(毫不夸张).我现在对它太烦了,以至于我陷入了@LazyOne附带(< 3)的建议.

我使用的是PhpStorm v.2020,而我使用的是Mac.


步骤1-安装SSHPASS

这是第一个障碍.有几个不同的水龙头在那里.


第4步-运行并测试

现在开始运行">>运行",然后选择您刚刚添加的那个.然后,您应该会看到一个像这样的窗口:

要再次运行最新的运行",只需按 CMD + r .

BAM!


第5步-将uploader.sh添加到.gitignore

现在,服务器的密码以纯文本格式存储在计算机上的文件中.出于安全目的,这是不好的.因此,如果您正在为核发射编写后端,那么您可能不应该这样做.

但是请记住将 uploader.sh 文件添加到您的 .gitignore 文件中,以避免将其上传到存储库中.

有用的资源

How can I upload a selection of files with a single shortcut in PhpStorm?

Ideally it uses the PhpStorm Deployment-mechanism, - but all answers are welcome. Such as making a bash-file, that scp's the files over (which is then executed using PhpStorm).

I'm looking for a way, where I can simply press something like: CMD + OPT + CTRL + J - and then it uploads all these marked files.

My project have below-shown structure. I've marked the files I would like to be able to upload with an (x):

project
|- subfolder
   |- subsubfolder
      |- assets
      |  |- css (x)
      |  |- js (x)
      |  |- admin (x)
      |  |- img
      |
      |- foo.php
      |- bar.php
      |- style.css (x)
      |- bundle.js (x)
      |- other.php
      |- other-1.php


Attempt1

I've already tried the: "Upload changed files automatically to the default server" == "Always|On explicit save..." - and it's quite magically. But if the setup isn't right - then it can mess up badly.

解决方案

Alright. This is how I did it. FINALLY!!! I've been looking for this for years (no exaggeration). I just got too annoyed with it now, that I dived down into the suggestion @LazyOne came with ( <3 ).

I using PhpStorm v. 2020 and I'm on a Mac.


Step 1 - Install SSHPASS

This was the first hurdle. There are a couple of different taps out there. This one worked for me:

brew install hudochenkov/sshpass/sshpass

This is necessary to avoid getting prompted for the password whenever the scp-command is executed.


Step 2 - Get SCP to work from a terminal

It's annoying to debug from inside PhpStorm. So I would suggest starting in the terminal, getting a SCP-command to work. It relative to soooo many things, so it might differ from one host to another.

Please note that SCP is using SSH to copy files, to SSH should be enabled for this to work.

Here's a command that works for me:

sshpass -p 'mypassword' scp style.css app.js SERVER_USER@SERVER_IP:public_html/wp-content/themes/my_theme_name/

This copies two files to the given destination.

Why I'm not using a SSH-key instead?

I'm on a server where there is a master-user, that I can add my ssh-key to - so that can access the server. But I can't do that for the individual instances.


Step 3 - Make a shell-script

I made a script called uploader.sh and added this content:

#!/bin/bash

sshpass -p 'mypassword' scp myfile.css anotherfile.js athirdfile.php SERVER_USER@SERVER_IP:public_html/wp-content/themes/my_theme_name/

Then I went to 'Run' >> 'Edit configurations' and add a new Shell-file.

Note!! Remember to uncheck 'Execute in terminal'. The reason being that it's nice to be able to just keep working whereever you are. And if you execute it in the terminal, then the cursor will finish in the terminal. If it's unchecked, then it doesn't do that.

Here you can see my configuration:


Step 4 - Run and test

Now go tho 'Run' >> 'Run' and choose the one you just added. Then you should see a window like this:

And to run latest 'Run' again, you can simply press CMD + r.

BAM!


Step 5 - Add uploader.sh to .gitignore

Now the password to your server is stored in clean-text in a file on your machine. It's bad for security purposed. So if you're coding a backend for nuclear launches, then you probably shouldn't do this.

But remember to add the uploader.sh file to your .gitignore-file to avoid uploading it to the repo.

Useful resources

这篇关于在PhpStorm中使用一个快捷方式上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆