Sascha's Digital Drawer

The Case of the Missing Variable

It’s a tale as old as time (or at least as old as Windows 10).

I sat down at my laptop, coffee in hand, fired up VS Code, and prepared to commit some questionable PHP code. I opened the integrated terminal, typed php -v just to make sure I was sane, and…

'php' is not recognized as an internal or external command,
operable program or batch file.

The Mental Audit

My first reaction was the classic developer denial: I didn’t touch anything.

I started running through the checklist in my head:

  1. Is XAMPP running? Yes, the Apache service is green.
  2. Does the file exist? I navigated to C:\xampp\php and sure enough, php.exe was staring right at me.
  3. Did I break my shell? tried git status. Works fine. node -v. Works fine.
  4. What changed? Ah. The blue screen of “Updates are underway” during my lunch break.

The Culprit: Windows Update

A quick trip to System Properties > Environment Variables confirmed my suspicion.

For some reason, the Windows update process decided that my user-defined Path variable was too cluttered and “optimized” it by removing “unnecessary” entries. Gone were references to C:\xampp\php, C:\ProgramData\ComposerSetup\bin, and a few other custom tools I use daily.

I’m not one to wear a tinfoil hat, but it felt like a subtle hint from the OS to stop writing PHP and switch to C#.

The Fix

Re-adding the variables is trivial, but remembering which ones were there is the annoyance.

  1. Search for “Edit the system environment variables” in the start menu.
  2. Click Environment Variables.
  3. Under System variables (or User variables, depending on how you roll), find Path.
  4. Click Edit and add your paths back:
    • C:\xampp\php (or wherever your executable lives)
    • C:\Users\Sascha\AppData\Roaming\Composer\vendor\bin (if you use global composer packages)

The Lesson

The lesson here isn’t just “fix the path.” It’s to stop assuming your environment is static. Windows updates are chaotic neutral. They will reset drivers, change default audio devices, and apparently, prune your environment variables.

Pro Tip: Export your Path variable to a text file every once in a while. It’s the “did you try turning it off and on again” of the DevOps world, but for your sanity.

← Back to all posts