Urgent.News

What's breaking now, across thousands of outlets.

Tech

Using WP-CLI aliases to switch between multiple WordPress environments safely

Anyone managing several WordPress environments — production, staging, or separate installs for different languages — ends up re-typing SSH connection details and install paths every time they run a command. Building that connection string by hand each time invites mistakes: a copy-paste error, or reusing a stale path, can send a command to the wrong environment entirely. That risk matters most…

Managing multiple WordPress environments can be a hassle, especially when it comes to typing out connection details and installation paths for each command. These errors are even more dangerous when running write commands, as they could potentially affect the wrong environment. WP-CLI offers a solution with its alias feature, which allows users to assign a short name like @production to a set of connection details, including SSH targets and WordPress install paths. Once registered, the short name replaces the full connection string for every subsequent command.

These aliases are typically stored in two config files: wp-cli.yml in the project directory or ~/.wp-cli/config.yml in the home directory. The project-level file takes precedence if the same alias exists in both. When working across multiple environments, it's better to consolidate aliases in the home directory to avoid confusion.

To use an alias, simply run the command with the alias name, like wp @production plugin list. WP-CLI will then execute the command against the remote WordPress install over SSH, just as if it had been run locally.

For single environments, individual aliases can be bundled into group aliases for easier execution. For example, @all can be used to run a command against both @production and @staging. This makes it easy to see which result belongs to which site, providing a form of record-keeping.

However, when using aliases, it's important to keep a few things in mind. Name aliases so that the environment is obvious, and avoid using short forms that could become ambiguous. It's also a good practice to run wp cli alias list before executing anything unfamiliar to review the currently registered aliases and their targets. Finally, avoid running write commands through a group alias, as this could lead to unintended consequences if something goes wrong.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

The Wildcard Scope Problem: Why MCP Configs Default to admin:* Instead of Least Privilege

If you grep your own mcp.json files right now, there's a decent chance you'll find a scope string that looks like "admin:*" or "full_access" somewhere.

  • Many MCP configurations default to wildcard scopes like admin: instead of least privilege.
  • Sentinel-scan-cli tool flags wildcard scopes as a simple but effective security rule.
  • Explicitly defining permissions instead of wildcards improves auditability and security.

I Wanted to Press F5 and Debug JavaScript — So I Built My Own VS Code Debugger

Sometimes software development reaches a point where the tools designed to make your job easier start becoming part of the job. I ran into that with browser debugging.

  • CloudIDEaaS simplifies JavaScript debugging by automating setup tasks.
  • Enables developers to focus on debugging, not configuration.
  • Free and open-source under MIT license, welcomes developer feedback.

More from Monday 31 August →