DevZero Logo

DevZero

PhpStorm

Setting up PhpStorm to connect to DevZero workspaces.

From the dz CLI

dz workspace phpstorm <workspace-name | workspace-id>

Add to recipe

- type: command
  command: |
    IDE_HUMAN_NAME="PhpStorm"
    IDE_NAME="phpstorm"
    PRODUCT_CODE="PS"
    VMOPTIONS_FILE="phpstorm64.vmoptions"

    if [ -d "/opt/ide/jetbrains/$IDE_NAME" ]; then
        print "$("Directory for $IDE_HUMAN_NAME exists, not taking any action")"
        exit 0
    fi

    wget --quiet --output-document="/tmp/$IDE_NAME.tar.gz" "https://download.jetbrains.com/product?code=$PRODUCT_CODE&latest&distribution=linux"

    rm -rf /opt/ide/jetbrains/"$IDE_NAME"*

    mkdir -p "/opt/ide/jetbrains/$IDE_NAME"
    tar --strip-components=1 -xzf "/tmp/$IDE_NAME.tar.gz" -C "/opt/ide/jetbrains/$IDE_NAME"

    sed -i -E s/-Xmx.+/-Xmx8g/ "/opt/ide/jetbrains/$IDE_NAME/bin/$VMOPTIONS_FILE"
    sed -i -E s/-Xms.+/-Xms512m/ "/opt/ide/jetbrains/$IDE_NAME/bin/$VMOPTIONS_FILE"

    chmod g+w /etc/environment

    if ! grep -Fq "REMOTE_DEV_TRUST_PROJECTS" /etc/environment; then
        printf '\nREMOTE_DEV_TRUST_PROJECTS=1' | tee -a /etc/environment
    fi
    if ! grep -Fq "REMOTE_DEV_NON_INTERACTIVE" /etc/environment; then
        printf '\nREMOTE_DEV_NON_INTERACTIVE=1' | tee -a /etc/environment
    fi

    if id "devzero" &>/dev/null; then
        ## If the IDE is already installed this command echoes a message and returns exit code 1
        bash -c "sudo su devzero bash -c \"/opt/ide/jetbrains/$IDE_NAME/bin/remote-dev-server.sh registerBackendLocationForGateway\" || true "
    fi

    rm -rf "/tmp/$IDE_NAME.tar.gz"
  user: root
version: "3"
build:
  steps:
    - type: apt-get
      packages:
        [
          "build-essential",
          "curl",
          "git",
          "nano",
          "software-properties-common",
          "ssh",
          "sudo",
          "tar",
          "unzip",
          "vim",
          "wget",
          "zip",
        ]
    - type: command
      command: |
        IDE_HUMAN_NAME="PhpStorm"
        IDE_NAME="phpstorm"
        PRODUCT_CODE="PS"
        VMOPTIONS_FILE="phpstorm64.vmoptions"

        if [ -d "/opt/ide/jetbrains/$IDE_NAME" ]; then
            print "$("Directory for $IDE_HUMAN_NAME exists, not taking any action")"
            exit 0
        fi

        wget --quiet --output-document="/tmp/$IDE_NAME.tar.gz" "https://download.jetbrains.com/product?code=$PRODUCT_CODE&latest&distribution=linux"

        rm -rf /opt/ide/jetbrains/"$IDE_NAME"*

        mkdir -p "/opt/ide/jetbrains/$IDE_NAME"
        tar --strip-components=1 -xzf "/tmp/$IDE_NAME.tar.gz" -C "/opt/ide/jetbrains/$IDE_NAME"

        sed -i -E s/-Xmx.+/-Xmx8g/ "/opt/ide/jetbrains/$IDE_NAME/bin/$VMOPTIONS_FILE"
        sed -i -E s/-Xms.+/-Xms512m/ "/opt/ide/jetbrains/$IDE_NAME/bin/$VMOPTIONS_FILE"

        chmod g+w /etc/environment

        if ! grep -Fq "REMOTE_DEV_TRUST_PROJECTS" /etc/environment; then
            printf '\nREMOTE_DEV_TRUST_PROJECTS=1' | tee -a /etc/environment
        fi
        if ! grep -Fq "REMOTE_DEV_NON_INTERACTIVE" /etc/environment; then
            printf '\nREMOTE_DEV_NON_INTERACTIVE=1' | tee -a /etc/environment
        fi

        if id "devzero" &>/dev/null; then
            ## If the IDE is already installed this command echoes a message and returns exit code 1
            bash -c "sudo su devzero bash -c \"/opt/ide/jetbrains/$IDE_NAME/bin/remote-dev-server.sh registerBackendLocationForGateway\" || true "
        fi

        rm -rf "/tmp/$IDE_NAME.tar.gz"
      user: root