Upload code to (dev) server automatically

IDE configuration

PHPStorm (or other Intellij IDE)

Tools –> Deployment –> Configuration

Configure connection to server
  • Type: SFTP
  • SSH configuration: configure ssh connection to server using host, username, password or private key
  • Root path: root path to the deploy folder
Mapping configuration
  • 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
Excluded Paths
  • 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"
    ]
}
Leave a Reply 0

Your email address will not be published. Required fields are marked *