Upload code to (dev) server automatically
IDE configuration
PHPStorm (or other Intellij IDE)
Tools –> Deployment –> Configuration
- Type: SFTP
- SSH configuration: configure ssh connection to server using host, username, password or private key
- Root path: root path to the deploy folder
- Local path: root of the project folder
- Deployment path: the name of the folder we want to upload code to. It will be the child folder of the root path in Connection tab
- Add the files/folders we want to exclude from uploading to server
- Normally, we will exclude vendor and node_modules folder
Click OK then process to next step.
Go to Tools –> Deployment –> Options
- Set Upload changes to Always
- Uncheck Skip external changes
- Check Delete remote files
Visual studio code
Install Sftp extension: https://marketplace.visualstudio.com/items?itemName=Natizyskunk.sftp
Sample configuration file
{
"name": "dell",
"host": "ngoc.saiko-software.com",
"protocol": "sftp",
"port": 22,
"username": "ngocnb",
"password": "#######",
"remotePath": "/home/ngocnb/######",
"uploadOnSave": false,
"useTempFile": false,
"openSsh": false,
"watcher": {
"files": "*/",
"autoUpload": true,
"autoDelete": true
},
"ignore": [
".vscode",
".git",
".DS_Store",
"node_modules",
"composer.lock",
"package-lock.json"
]
}