| name | devops-warden |
| description | Run Magento 2 CLI commands through Warden's Docker environment: warden shell, bin/magento, composer, Redis/Valkey, Varnish, OpenSearch, RabbitMQ, n98-magerun2, mutagen sync, and env lifecycle. |
| installed_version | 1.1.0 |
| magehub_version | 0.1.13 |
Warden Local Environment
Activation
Use When
- The task needs Magento CLI, Composer, PHP, database, cache, search, queue, or filesystem-sync work inside a Warden-managed local environment.
- The user mentions warden, Docker local stack, Redis/Valkey, Varnish, OpenSearch/Elasticsearch, RabbitMQ, Mutagen, or n98-magerun2.
Do Not Use When
- The project uses DDEV, docker compose, Kubernetes, Adobe Cloud tooling, or another wrapper and no Warden files or commands are present.
- The request is purely code editing and does not require running Magento/runtime commands.
Required Inputs
- Project root containing the Warden .env file and the specific service or Magento command to operate.
- Whether the operation is read-only, cache-clearing, data-changing, or destructive.
Workflow
- Start with read-only environment discovery from the project root: git status, Warden env name, service status, and relevant logs.
- Run PHP, Composer, bin/magento, and n98-magerun2 only through warden shell or the project wrapper.
- Prefer targeted service operations over broad restarts or full cache/storage resets.
- After any operational change, run the smallest command that proves the service or Magento state recovered.
Guardrails
- Never run project PHP, Composer, or bin/magento directly on the host when a Warden environment is in use.
- Ask before running warden env down -v, deleting search indices, purging RabbitMQ queues, flushing Redis/Valkey, or importing a database. (approval required)
- Do not run destructive or data-changing commands against production or shared staging environments. (approval required)
Verification
- For shell/Magento work, report the exact warden shell command or wrapper used and the command exit result.
- For cache/search/queue changes, run a read-only status command afterward, such as cache:status, indexer:status, cluster health, or list_queues.
- For sync issues, confirm warden sync list or warden sync monitor output before and after recovery.
Output Contract
- Classify commands as read-only, reversible, data-changing, or destructive.
- Report the environment name, service touched, command results, and any approval-sensitive command skipped or executed.
Warden as the Only Execution Surface
Warden runs the full local stack (PHP-FPM, nginx, MariaDB, Redis/Valkey,
OpenSearch, Varnish, RabbitMQ) inside Docker. The host machine is not a
supported execution environment for Magento commands. Every php,
composer, and bin/magento invocation must go through warden shell
(or warden debug when Xdebug is needed). Running these on the host
produces generated code for the wrong PHP version, a composer.lock that
does not match the container, and cache/permission state that only the
container can repair.
Environment Lifecycle
Warden reads WARDEN_ENV_NAME (and other stack flags such as
WARDEN_REDIS, WARDEN_VARNISH, WARDEN_RABBITMQ) from the .env
file in the project root. Always run lifecycle commands from that
directory so Warden resolves the correct environment name and
docker-compose overrides.
Use lifecycle commands from the project root:
warden env start — start a stopped environment
warden env stop — stop without destroying volumes
warden env down -v — destructive: removes all volumes (DB,
Redis, search index). Only use when resetting a broken env.
warden env config — print the resolved docker-compose configuration,
useful when diagnosing service overrides
warden env logs --tail 0 -f nginx php-fpm php-debug — tail the
request/PHP logs live; --tail 0 skips the backlog so you only see
new events
Shell Access
warden shell — php-fpm container shell. Default entrypoint for all
Magento CLI work: bin/magento, composer, php, n98-magerun2.
warden debug — php-fpm container shell with Xdebug enabled. Use
this only when stepping through code; Xdebug adds per-request overhead
so keep it scoped to the debug session.
Both shells drop you into the project root inside the container with
the application user's uid/gid, so file ownership stays correct when
writing to generated/, var/, or pub/static.
Database
- Import a dump (preferred, streaming):
pv /path/to/dump.sql.gz | gunzip -c | warden db import
Substitute cat for pv if the progress bar is unavailable.
- Live connection:
warden db connect (drops into the MariaDB client)
- Watch the processlist:
watch -n 3 "warden db connect -A -e 'show processlist'"
Useful for spotting stuck upgrades, runaway indexers, or slow admin
grids during investigation.
Redis and Valkey
Magento stores cache and session data in Redis (or Valkey, the Redis
fork some stacks use). Warden exposes both:
warden redis / warden valkey — connect to the CLI
warden redis flushall / warden valkey flushall — clear every key.
Reach for this when bin/magento cache:flush alone does not resolve
stale behavior; page-cache entries and session data live outside
Magento's cache-type registry.
warden redis --stat — continuous stat mode for watching connection
and memory pressure during load tests.
Varnish
Varnish sits in front of nginx and caches full-page responses. Operate
it through the container directly:
- Tail activity:
warden env exec -T varnish varnishlog
- Ban all cached objects (preferred over restart):
warden env exec -T varnish varnishadm 'ban req.url ~ .'
A ban keeps warm connections and lets Varnish rebuild lazily; restarting
the container evicts everything at once and disrupts active traffic.
Troubleshooting
When commands fail in unexpected ways — warden shell hangs, nginx
502s, SSL warnings, DNS resolver errors — run warden doctor before
investigating the application. It inspects Docker state, the local
DNS resolver, root CA trust, and mutagen session health. Add -v
(warden doctor -v) to include environment variables in the output.
n98-magerun2
n98-magerun2 is pre-installed inside the php-fpm container and is
accessible from any warden shell session. Use it for admin tasks and
one-off data operations that would otherwise require a custom PHP script:
n98-magerun2 sys:info — PHP version, Magento edition/version, and
active modules summary
n98-magerun2 config:store:get web/secure/base_url — read a
core_config_data value without touching the DB directly
n98-magerun2 config:store:set --scope=default --scope-id=0 \ dev/debug/template_hints_storefront 1 — write a config value
n98-magerun2 admin:user:create — interactive wizard to create an
admin user (avoids writing a throwaway script)
n98-magerun2 admin:user:change-password admin@example.com — reset
a password without touching the DB
n98-magerun2 db:query "SELECT entity_id, sku FROM catalog_product_entity LIMIT 10" — one-off SQL without opening a full DB session
n98-magerun2 cache:clean — clean specific cache types interactively
n98-magerun2 index:list — show indexer status (same data as
bin/magento indexer:status but in a compact table)
OpenSearch / Elasticsearch
Magento's catalog and search indexers store data in OpenSearch (or
Elasticsearch on older stacks). Access it through the opensearch
container:
When a reindex fails with a connection error, check cluster health first
before investigating the PHP layer — a yellow or red cluster status (too
few replicas or an out-of-disk node) blocks all write operations.
RabbitMQ
Magento uses RabbitMQ to process asynchronous operations (bulk API,
Async/Bulk REST, inventory reservations). Inspect and manage queues
through the rabbitmq container:
- List all queues and their message counts:
warden env exec -T rabbitmq rabbitmqctl list_queues name messages consumers
- Purge a stale queue (removes all unconsumed messages):
warden env exec -T rabbitmq rabbitmqctl purge_queue async.operations.all
- Run a Magento consumer from inside
warden shell:
bin/magento queue:consumers:start async.operations.all --max-messages=100
- Run all consumers in the background (development shortcut):
bin/magento queue:consumers:start --all &
- Management UI: available at
https://rabbitmq.{WARDEN_ENV_NAME}.test (default credentials:
guest / guest). Useful for inspecting bindings, exchanges, and
per-queue message rates without CLI commands.
File Sync (mutagen)
Warden uses mutagen to keep files on the host and inside the php-fpm
container in sync. The sync session can stall after Docker Desktop
restarts, wakes from sleep, or following a warden env stop/start
cycle.
warden sync list — show all active sync sessions and their state
warden sync monitor — stream live sync events (Ctrl-C to exit);
confirms whether the session is actively propagating changes
warden sync pause / warden sync resume — temporarily halt sync
without destroying the session (useful during large file operations)
warden sync restart — stop and recreate all sync sessions; the
first choice when edits on the host are not reaching the container
warden sync reset — nuke the sync state entirely and force a full
re-scan; use only when warden sync restart does not resolve the
conflict
If a file edited on the host never appears inside warden shell, run
warden sync monitor first to confirm sync is live before investigating
file permissions or editor save behaviour.
Where to Learn More
warden help — top-level command index
warden env -h — environment-subcommand reference
- https://docs.warden.dev/ — canonical documentation
Conventions
- Never run php, composer, or bin/magento on the host — always enter the container first with
warden shell
Example: warden shell # then inside: bin/magento setup:upgrade
Rationale: The host machine usually has a different PHP version, no Magento extensions (sodium, intl, bcmath at the right versions), and no access to the MySQL/Redis/OpenSearch services on the internal Docker network. Running commands on the host either fails outright or — worse — succeeds with the wrong toolchain and corrupts generated/, var/cache, or composer.lock in ways that only show up later.
- Use
warden debug when you need Xdebug — warden shell starts a non-debug PHP-FPM session
Example: warden debug # Xdebug auto-connects to the IDE on the configured port
Rationale: Xdebug adds measurable overhead on every request, so the default shell omits it. Opening a debug shell is an explicit opt-in that isolates slow paths to the session that actually needs the debugger.
- Pipe gzipped SQL dumps into
warden db import rather than copying the file into the container first
Example: pv /path/to/dump.sql.gz | gunzip -c | warden db import
Rationale: Streaming avoids materializing a multi-gigabyte SQL file inside the db container volume. pv also shows a progress bar so long imports are observable; fall back to cat when pv is not installed.
- Flush Redis/Valkey after configuration changes or cache-related debugging, not just bin/magento cache:flush
Example: warden redis flushall # or: warden valkey flushall
Rationale: bin/magento cache:flush only clears the cache types Magento knows about. Session data, page cache entries written by Varnish/Redis directly, and keys from third-party modules can persist and mask the change you just made. A full flush is the only way to know you're seeing fresh state.
- Invalidate Varnish with a ban rule rather than restarting the container
Example: warden env exec -T varnish varnishadm 'ban req.url ~ .'
Rationale: Restarting Varnish drops warm connections and evicts every object. A ban with
req.url ~ . matches every URL and lets Varnish rebuild lazily as traffic returns, which is faster and less disruptive than a cold start.
- Run
warden env down -v only when you intentionally want to discard volumes (database, Redis, Elasticsearch data)
Example: warden env down -v # destructive — wipes all env volumes
Rationale: The -v flag removes named volumes. Use warden env stop for a reversible pause. Reach for down -v only when resetting a corrupted DB or freeing disk — and confirm there is no unsaved state first.
- Use n98-magerun2 for admin tasks and one-off data queries instead of writing throwaway scripts
Example: n98-magerun2 admin:user:create # interactive; no need for a custom PHP script
Rationale: n98-magerun2 is available inside warden shell and covers the most frequent admin tasks (user management, config reads/writes, one-off SQL, cache operations) faster and more safely than a raw bin/magento or custom PHP script.
- Run
warden sync monitor when files edited on the host are not reflected inside the container
Example: warden sync monitor # streams mutagen sync events until Ctrl-C
Rationale: Warden uses mutagen for bidirectional file sync. When the sync session stalls (common after Docker Desktop restarts or long sleep cycles), edited files silently stop reaching the container. warden sync monitor confirms whether sync is live; if it shows conflicts or a stalled state, restart with warden sync restart.
Examples
Entering the shell and running Magento commands
Canonical flow for any bin/magento, composer, or php task — enter the container, run the command, exit
#!/usr/bin/env bash
warden shell
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f en_US
bin/magento cache:flush
bin/magento indexer:reindex
composer install --no-interaction
composer require vendor/module:^1.2
php -v
php -m | grep -i intl
exit
Importing a gzipped database dump
Stream a compressed SQL file into the db container with a progress bar
#!/usr/bin/env bash
pv /path/to/dump.sql.gz | gunzip -c | warden db import
cat /path/to/dump.sql.gz | gunzip -c | warden db import
pv /path/to/dump.sql | warden db import
watch -n 3 "warden db connect -A -e 'show processlist'"
Redis and Valkey operations
Connect, flush, and monitor Redis or Valkey through Warden
#!/usr/bin/env bash
warden redis
warden valkey
warden redis flushall
warden valkey flushall
warden redis --stat
warden redis INFO memory
warden redis DBSIZE
warden redis KEYS 'zc:*' | head
Varnish cache invalidation
Tail Varnish activity and ban all cached objects without restarting the service
#!/usr/bin/env bash
warden env exec -T varnish varnishlog
warden env exec -T varnish varnishadm 'ban req.url ~ .'
warden env exec -T varnish varnishadm 'ban req.url ~ ^/catalog/product/'
warden env exec -T varnish varnishadm 'ban.list'
Environment lifecycle and diagnostics
Start, stop, inspect logs, resolve config, and run warden doctor
#!/usr/bin/env bash
warden env start
warden env stop
warden env down -v
warden env config
warden env logs --tail 0 -f nginx php-fpm php-debug
warden doctor
warden doctor -v
warden help
warden env -h
n98-magerun2 common commands
Admin user management, config reads, one-off SQL queries, and cache operations via n98-magerun2 inside warden shell
#!/usr/bin/env bash
n98-magerun2 sys:info
n98-magerun2 module:list --status=enabled
n98-magerun2 config:store:get web/secure/base_url
n98-magerun2 config:store:get --scope=websites --scope-id=1 web/unsecure/base_url
n98-magerun2 config:store:set --scope=default --scope-id=0 \
dev/debug/template_hints_storefront 1
n98-magerun2 config:store:delete dev/debug/template_hints_storefront
n98-magerun2 admin:user:create
n98-magerun2 admin:user:change-password admin@example.com
n98-magerun2 admin:user:list
n98-magerun2 db:query "SELECT entity_id, sku, type_id FROM catalog_product_entity LIMIT 10"
n98-magerun2 db:query \
"SELECT scope, scope_id, value FROM core_config_data WHERE path = 'web/secure/base_url'"
n98-magerun2 cache:clean
n98-magerun2 cache:flush
n98-magerun2 cache:list
n98-magerun2 index:list
n98-magerun2 index:reindex:all
OpenSearch / Elasticsearch operations
Check cluster health, list indices, reset and reindex Magento indexers, and tail OpenSearch logs
#!/usr/bin/env bash
warden env exec -T opensearch curl -s localhost:9200/_cluster/health \
| python3 -m json.tool
warden env exec -T opensearch curl -s 'localhost:9200/_cluster/health?pretty'
warden env exec -T opensearch curl -s 'localhost:9200/_cat/indices?v'
warden env exec -T opensearch curl -s 'localhost:9200/_cat/indices/magento2*?v'
warden env exec -T opensearch \
curl -s 'localhost:9200/magento2_product_1/_settings' | python3 -m json.tool
warden env exec -T opensearch curl -s -X DELETE localhost:9200/magento2_product_1
warden env exec -T opensearch curl -s -X DELETE 'localhost:9200/magento2*'
bin/magento indexer:reset catalogsearch_fulltext
bin/magento indexer:reindex catalogsearch_fulltext
bin/magento indexer:reset \
catalogsearch_fulltext \
catalog_category_product \
catalog_product_category \
catalog_product_price
bin/magento indexer:reindex
bin/magento indexer:status
warden env logs --tail 0 -f opensearch
warden env logs --tail 100 opensearch
RabbitMQ queue management
List queues, purge stale messages, run consumers, and access the Management UI
#!/usr/bin/env bash
warden env exec -T rabbitmq rabbitmqctl list_queues name messages consumers
warden env exec -T rabbitmq rabbitmqctl list_queues name messages consumers \
| sort -k2 -rn
warden env exec -T rabbitmq rabbitmqctl list_queues \
name state messages memory idle_since
warden env exec -T rabbitmq rabbitmqctl purge_queue async.operations.all
warden env exec -T rabbitmq rabbitmqctl purge_queue async.operations.all
warden env exec -T rabbitmq rabbitmqctl purge_queue inventory.reservations.update
warden env exec -T rabbitmq rabbitmqctl purge_queue media.storage.catalog.image.resize
bin/magento queue:consumers:start async.operations.all --max-messages=100
bin/magento queue:consumers:start async.operations.all \
--single-thread \
--max-messages=10
bin/magento queue:consumers:start --all &
bin/magento queue:consumers:list
warden env exec -T rabbitmq rabbitmqctl list_vhosts
warden env exec -T rabbitmq rabbitmqctl list_exchanges
warden env exec -T rabbitmq rabbitmqctl list_connections \
peer_host peer_port user state
warden env logs --tail 0 -f rabbitmq
File sync (mutagen) operations
Start, stop, monitor, and recover the mutagen sync session that keeps host and container files in sync
#!/usr/bin/env bash
warden sync list
warden sync monitor
warden sync start
warden sync stop
warden sync pause
warden sync resume
warden sync restart
warden sync reset
warden doctor
warden doctor -v
mutagen daemon stop && mutagen daemon start
warden sync start
Anti-patterns
- Running
composer install or bin/magento setup:upgrade on the host machine: The host PHP binary and extensions almost never match the container. Composer resolves platform requirements against the wrong PHP version, writes an incompatible composer.lock, and Magento setup writes generated code (generated/code, generated/metadata) built for the host toolchain. The app then fails to boot inside the container with cryptic class-loading errors.
Solution: Always warden shell first. Run composer, bin/magento, and any php script from inside the php-fpm container so the toolchain, extensions, and file ownership match what the running application sees.
- Copying a SQL dump into the db container with
docker cp before importing: Large dumps balloon the container filesystem, slow down disk I/O for the live DB, and leave orphan files that are easy to forget. The copy step also doubles the time to import.
Solution: Stream directly: pv dump.sql.gz | gunzip -c | warden db import. Nothing is written to disk inside the container, and pv reports throughput so you know the import is making progress.
- Restarting containers to clear caches: Container restarts drop all in-memory state (Redis keys, Varnish objects, OPcache), break active debugging sessions, and take far longer than targeted cache operations. They also mask real bugs by forcing a cold-start that hides stale-config issues.
Solution: Use the targeted tool:
warden redis flushall for Redis, warden valkey flushall for Valkey, the varnishadm ban for Varnish, and bin/magento cache:flush for Magento-managed caches. Restart only when a service is actually unhealthy.
- Debugging silent failures without checking
warden doctor: Warden depends on Docker, mutagen, DNS resolution, and traefik routing. When one piece drifts (expired certs, stale resolver, Docker Desktop update), commands fail in confusing ways — warden shell hangs, URLs 502, or env vars don't load. Hours get spent chasing application-layer causes for an environment-layer problem.
Solution: Run warden doctor (or warden doctor -v for environment variables) at the first sign of unexplained environment behavior. It reports Docker state, DNS resolver config, root certificate trust, and mutagen session health in one pass.
References
Freshness
- Last reviewed: 2026-06-28
- Sources to re-check: Warden local development documentation, Adobe Commerce 2.4.x operations docs