wp-cli/search-replace-command
WP-CLI command for safe search-and-replace across a WordPress database. Update URLs, domains, or any string in all tables with dry-run previews, regex, case-insensitive matching, and familiar WP-CLI syntax—ideal for migrations and environment changes.
wp_options, wp_usermeta, and page-builder meta — which is exactly where hand-written UPDATE ... REPLACE() statements silently break sites. That makes it a buy-not-build decision: the alternative is a bespoke script that costs engineering days and fails on serialized lengths.www cutover leaves mixed-content references, this is the standard remediation path. Worth a runbook entry so support can resolve it without escalating to engineering.--dry-run and --report-changed-only output gives you a countable blast radius before you commit — that's the artifact you take into a go/no-go review.Caveat to carry into every one of these: this is not a Laravel/Composer package. It's a WP-CLI command for WordPress databases. If the decision at hand concerns a pure Laravel schema, it is out of scope — treat it as a WordPress-operations tool that happens to live in the PHP toolchain.
Adopt (or rather, standardize on) it when:
wp_options or post meta holds serialized arrays (page builders, SEO plugins, widget config), a naive SQL replace is a data-corruption risk. This is the single strongest reason to use it.http→https, path prefixes, brand renames. Not schema changes, not content restructuring.Look elsewhere when:
DB::table()->update() or raw SQL you control, plus a proper test. Installing a WP-CLI command into a Laravel app is a category error.--all-tables fits your downtime tolerance before committing.For executives (one paragraph): This is a small, free, MIT-licensed maintenance tool for our WordPress data, and it de-risks the two moments that most often break a WordPress site: moving it between environments and changing its domain. The failure mode it prevents is subtle — content stored in a serialized format gets silently corrupted by ordinary database edits, which surfaces later as broken page layouts and lost settings. Using the standard command instead of a custom script removes that class of incident for roughly the cost of a runbook entry. It is not a strategic investment and not a Laravel dependency; it's hygiene for any WordPress property we keep in the portfolio.
For engineering (one paragraph): wp-cli/search-replace-command is a bundled WP-CLI subcommand (wp search-replace), not a Composer library — do not add it to a Laravel composer.json. It rewrites strings across tables while correctly re-serializing PHP-serialized values and updating their length prefixes, with --dry-run, --report-changed-only, --all-tables, --skip-columns, --precise, and --recurse-objects for controlled execution. Operating rules: always take a dump first (no rollback), always dry-run and record the changed-row counts, scope to --all-tables only when you actually need it, and run inside a maintenance window on large datasets. Known limits: it's string-level only — no shortcode, taxonomy, or block conversion, and JSON payloads nested inside serialized or escaped strings deserve a spot check. If we ever consolidate WordPress content into the Laravel app, this is the normalization step upstream of the ETL, budgeted as a day, not a project.
Ask: approve a one-page runbook plus a pinned WP-CLI version across environments; no procurement, no new vendor.
How can I help you explore Laravel packages today?