Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Db Command Laravel Package

wp-cli/db-command

WP-CLI command package for running basic database operations using credentials from wp-config.php. Create, drop, reset, export, import, optimize, repair, check, and query databases, plus list tables and run SQL directly from the command line.

View on GitHub
Deep Wiki
Context7

WP-CLI DB Command provides WP-CLI commands for performing basic database operations using credentials stored in wp-config.php. It lets you create, drop, reset, clean, query, export, and import WordPress databases directly from the command line.

  • Create, drop, and reset databases without manual MySQL access.
  • Clean all tables matching the configured $table_prefix.
  • Run SQL queries from files or standard input.
  • Export and import database dumps for backups or migrations.
  • Support custom DB user/password and optional MySQL defaults files.
Frequently asked questions about Db Command
Can I use wp-cli/db-command directly inside a Laravel application?
Not in-process. wp-cli/db-command is a WP-CLI bundle command, not an application library, and it exposes no PHP API, facade, or service contract you can call from Laravel. Requiring it into a Laravel app is not recommended because it pulls WP-CLI framework constraints into a codebase that already pins Symfony Console. The viable pattern is to treat it as an external shell command invoked through Laravel's Process component or a queue job.
How do I install wp-cli/db-command for a Laravel-hosted WordPress control plane?
In most cases you do not install it individually: it ships inside wp-cli.phar and wp-cli/wp-cli-bundle, so it is already present on a normal WP-CLI install. Verify with wp db --help or wp cli version on the host that runs WordPress, not inside the Laravel application. If you truly need the Composer package, install it on the WordPress host or CI image where WP-CLI executes, not as a Laravel application dependency.
Does wp-cli/db-command support Laravel 10 or Laravel 11?
There is no Laravel version compatibility matrix because the package is not a Laravel package and Laravel never loads it in-process. What matters is the PHP version required by the pinned WP-CLI release and whether the WordPress host satisfies it, plus the MySQL or MariaDB server version. Check composer show wp-cli/db-command and wp cli version on the target host before pinning.
How do I export a WordPress database from a Laravel queue job?
Run wp db export through Laravel's Process component over SSH or inside the WordPress container, write the SQL artifact to object storage, and record the result in your job. Keep credentials scoped and avoid putting passwords on argv where ps can see them. This fleet-control-plane pattern matches how managed WordPress platforms operate and is the high-value integration path.
What are the production risks of wp db drop, wp db reset, and wp db clean?
These are destructive verbs that accept --yes and have no dry-run, so a mistyped environment or prefix can remove the wrong data. wp db clean drops every table matching $table_prefix, which is especially dangerous on shared or multisite databases. Imports are not wrapped in a transaction, so a killed process can leave a partially restored schema. Gate these commands behind strict allowlists and confirmation in your Laravel control plane.
How does wp db clean decide which tables to drop?
It runs DROP_TABLE for every table whose name begins with the $table_prefix configured in wp-config.php. The docs note that the global --url parameter has no effect on wp db query, so do not rely on multisite URL selection for safety. Verify the prefix for the target site before running clean, particularly on shared or multisite databases.
Why does wp db query behave differently from the mysql client?
The maintainers strip WordPress-incompatible SQL modes such as NO_ZERO_DATE and STRICT_TRANS_TABLES by default so queries behave like wpdb, and the newer --skip-sql-mode-compat flag exposes that behavior. That is mature, but it means query semantics differ from a bare mysql client. Engineers pasting production debugging commands between tools should expect different strictness and date handling.
Do I need MySQL client binaries installed to use wp-cli/db-command?
Yes. The package is a thin wrapper around the mysql, mysqldump, and mysqlcheck client binaries, so a slim or Alpine-based image without those tools will fail on first run. Install the MySQL or MariaDB client package in the WordPress container or CI image and confirm the binaries are on PATH. This is the most common first-run failure for this package.
How should I pass database passwords securely to wp db commands?
Avoid putting passwords on argv with --dbpass because other processes may see the command line. Prefer environment-based credentials or a carefully scoped option file, and remember that --defaults loads the host's MySQL option files and is off by default. Enable --defaults only when a specific host requires it, and confirm whether the pinned release passes MYSQL_PWD via the environment before choosing.
Is wp-cli/db-command actively maintained and what are the alternatives?
It is the canonical WP-CLI database interface and ships in the standard bundle, so its low star count and zero Composer dependents understate real adoption. Verify release tags against the reported 2026-08-14 date before pinning, since future-dated metadata should not be used as a constraint without a composer show or wp cli version check. Alternatives are raw mysql and mysqldump scripts or custom Artisan commands, but those lose the wp-config.php credential resolution and WP-CLI guardrails.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo