Yup, I’m sold. Building out a theme in React (w/ Frontity.org) is a lot of fun. I work with PHP all day, so building w/ JS is really refreshing/revitalizing. Got about a dozen more things for this site, then will launch the site decoupled and push the code to Github. 👨‍💻

Playing around with code-server, it was pretty cool to see VS Code in the browser with github.dev, but to have running in Docker on my Raspberry Pi for my local projects – that’s really cool.

Not totally sure this is a solution to any problem I have.. it allows me to code from the iPad I suppose, but I’d rather have a full macbook for all the other dev tools I need (Alfred, text expander, better multitasking / window management, the esc key [instead of cmd+.], the “next” song button, etc). But still. Cool. 😎

Really curious what the experience of building a WordPress site would be like now with full site editing. I’ve coded dozens and dozens of big and small PHP WordPress themes.. really thinking about redoing this site with blocks just to get a hands on idea of what’s involved building one out. 🤔

I spend a large portion of my day copying my CLI commands and sharing with others, as such I didn’t want the path or repo status in my terminal, but did want “$” to help indicate it’s a terminal command. Not finding something minimal on the Oh My ZSH themes, I created this simple one:

It’s simply $, nothing else. No bells, no whistles. & yes, I use $ pwd a lot.

Working on my website right now — trying to add a feature, but need to fix two other things to even start on that. Trying to fix the two other things, & need to fix four other things to move them forward. So deep in it now I don’t even remember what I was doing – ah how I’ve missed developing. 👨‍💻

Convert Alfred snippets (.json) to Espanso matches (.yaml)

Moving to Linux this month (Pop_OS to be specific), the biggest change was leaving Alfred behind. While almost every other tool or app had a nearly exact replacement, I could not find any launchers on Linux that had the huge number of power user features Alfred has. However, I found lots of amazing small apps that do just one feature and do it well.

One of those apps was Espanso, a light weight CLI focused text expander. Using Alfred on macOS, the global snippets where a big part of my workflow. After a bit of reading, on Linux I stumbled on Espanso which seems like one of the best text expanders available. A quick browse of the well written and maintained documentation and it’s clear why.

The UX for the actual text expanding was the exact same, however the setup was a bit different between the two apps. There’s no simple way to just import Alfred snippets into Espanso, so a bit of data massaging was required.

To do this I first exported Alfred snippets (either by browsing Alfreds preferences folder, or Exporting the snippets manually in Alfred > Features > Snippets > Export), I then jotted up and ran this script to convert Alfreds method of storing the snippets in .json to Espanso’s .yaml format, & tweaking some minor differences with cursor and clipboard variables:

A pretty simple difference and straight forward result. Then it was just copy & paste of the output to the bottom of ~/.config/espanso/default.yaml

If this doesn’t work and Espanso complains of errors, try opening default.yaml in VSCode or another editor and add YAML Syntax extension or similar. This should flag any syntax errors for manual resolving. In my case one or two regex patterns I have saved were just a bit to regex’y for my simple str_replace()’s.

All and all it wasn’t a heavy lift, & I managed to wrangle all 388 some snippets of mine over.

Troubleshooting xdebug setup on VVV with VS Code

Some tips for troubleshooting setting up xdebug on VVV while using VSCode and Felix Becker’s PHP Debug extension and BrianGilbert_‘s Xdebug Helper for Firefox add-on.

Ensure xdebug is turned on within vvv

You may check xdebug status by taking a peak at your servers http://vvv.test/phpinfo/ page. If not on, via https://github.com/Varying-Vagrant-Vagrants/VVV/wiki/Code-Debugging we can toggle it on by accessing the virtual machine via ssh, then running a command that will turn xdebug on and restart PHP:

$ cd ~/your/location/for/vvv/
$ vagrant ssh
$ /vagrant/config/homebin/xdebug_on

The xdebug_on command is supposed to work without the full path, but I haven’t much luck with that. As a second saver, I store this full path in my text expanded since every time the machine is restarted xdebug being on does not persist and it will need to be manually turned on. A bash_alias entry could be made as well.

Ensure the browser extension is turned on

Yes, simple, but often forgotten.

Ensure you’ve started debugging in VS Code

Again, yes, simple, but often forgotten.

Ensure VVV is up to date

Older versions of vvv have compatibility issues with xdebug and php. Ensure you’re running the latest version of vvv, that vagrant itself is up to date, and that you’re using the latest version of php.

Turn off “Everything” breaks

Sometimes xdebug works while setting it up, VSCode pops up, but it stops on a breakpoint that isn’t the one you specified, it’s a random file from your app. This is an error that was picked up and xdebug stoped on because the default VSCode extension has it specified to break on “everything”. Unselect this in the Debug sidebar:

Check the xdebug profile is correct

Via the debug sidebar (shift+cmd+d), we’ll view our xdebug configuration file. Here’s an example of a WordPress plugin delete-thumbnails and the path I used

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/srv/www/vvv-vip/public_html/wp-content/plugins/delete-thumbnails": "${workspaceFolder}"
            },
        }
    ]
}

Two important notes:

  • VVV has two initial paths to get to your sites, /srv/and /vagrant/, the latter is a symbolic link which xdebug does not understand, you must use /srv/
  • Other tutorials may say to use ${workspaceRoot}, this variable is deprecated in favor of ${workspaceFolder}

Try a breakpoint outside of your current script

We usually want our breakpoints on what we’re working on, and we’re frustrated when xdebug doesn’t pick up on the breakpoint, so we dig around our config to check what’s wrong. Let’s first make sure that our desired code is actually running and capable of breakpointing, after all, the code not running might be why we’re firing up xdebug!

Add a breakpoint at the root of your application, somewhere you know runs 100% for sure. In WordPress, this will often be in either WordPress’ /index.php file, or the primary file in your current theme or plugin. For this plugin I’m working on, I checked that the plugin is activated, and I’ve placed a breakpoints on a fake var on the main fire which I know for sure loads:

On Remote Servers: Check That Your Port is Open

Ensure you are connected to the server with an the posted specified open, & any port forwarding for the remote address is set in ~/.ssh/config

Is your VSCode the nightly build?

I’ve heard of users being unable to run xdebug while using their beta releases. Best to always use the stable releases.