My Remote Dev Environment

I juggle between three machines: a Windows PC where I spend 60% of my time playing games and doing the occasional scripting, a Macbook Air M3 I use when I’m on-the-go, and a Macbook Air M2 I use for legacy stuff for my dayjob.

Recently, I’ve switched away from PhpStorm to Cursor, and now I’m on Visual Studio Code with Copilot. Say what you want about AI, but Claude 3.7 is worth the money. The problem remains: when I switch machines (for travel or for basically anything else), the code I have in my Windows machine at home isn’t in any of my Macbooks.

The solution? Remote development.

VS Code + Remote SSH + Bash & Docker

TL;DR: The repository for my development environment can be found on GitHub: liamdemafelix/sandbox: Utilities and scripts for the dev sandbox.

I needed a development environment that:

  • I can use wherever I am and no matter which machine I’m on
  • Has near-native performance considering latency and network issues
  • Scriptable, so I can quickly get things running back up when needed

Since I mainly work with PHP and Linux, scripting this is easy. So, after a couple of hours and two cups of coffee, say hello to Sandbox Utilities.

Installing this is easy, all it needs is a fresh, Ubuntu 24.04 server with nothing else installed. Simply run the one-liner installation script:

curl -s https://raw.githubusercontent.com/liamdemafelix/sandbox/refs/heads/master/install.sh | bash

Run this from a normal account with sudo privileges so permissions aren’t all messed up.

P.S.: As of writing, it’s hardcoded to my name but I’ll tweak this so it can run with whatever username you have. If you want to try this out though, edit install.sh and replace all instances of liam with your Unix username.

This sets up the following:

  • Caddy, so you can get SSL-enabled sites with an easy-to-use configuration
    • Comes with a snippet for PHP so to set up a new site, all you have to add is a one-liner (see below)
  • PHP-FPM with versions from 5.6 to 8.3 via the Ondrej PPA
  • MariaDB
  • A PHP Switcher (php-switcher)
  • Composer, and a special composer shim, so when you call composer, it automatically knows which PHP version and Composer version to use
  • Node via nvm, with the latest LTS version automatically installed on first run

My Setup

Together with these scripts, I have a private domain name with a wildcard DNS record pointed to my Singapore-based server (for better latency). Then, in my Caddyfile, I just add:

import php mydomain.test.com /path/to/public 8.3

Where:

  • php tells Caddy that it’s a PHP app
  • mydomain.test.com is the domain I want to use for it
  • /path/to/public is the path to my document root
  • 8.3 is the PHP version I need to use for it

Caddy then automatically sets this up and fetches an SSL certificate, so I’m all set up just like that.

Because I have projects that use other PHP versions (with the oldest project using PHP 5.6), I also created a PHP Switcher:

Now, whenever you switch PHP versions using the PHP switcher, when you call composer, it would automatically use the correct Composer version (because PHP 5.6 doesn’t support the latest Composer version).

I also combined this with mailpit so I don’t need an SMTP server to test emails. I didn’t include this in the install script, but my config is in the repo: sandbox/mailpit at master · liamdemafelix/sandbox

Connecting VSCode via SSH

In the bottom-left corner, click the Connect icon and click Connect to Host, then feed it your SSH details. It will then do the initial setup on the server and once it’s finished, it’ll act like you’re working locally. VSCode basically acts as a “thin client”, and the software stack is on your server.

Leave a Reply

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