PHPackages                             cresset/magequery - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. cresset/magequery

ActiveLibrary[CLI &amp; Console](/categories/cli)

cresset/magequery
=================

A fast Magento 2 codebase inspector: DI resolution, plugins, events, cron, routes, config across scopes, and live DB introspection. Fetches a prebuilt Rust binary on demand.

v0.16.0(6y ago)21EUPL-1.2PHP &gt;=8.1

Since Jan 1Compare

[ Source](https://github.com/cresset-tools/magequery)[ Packagist](https://packagist.org/packages/cresset/magequery)[ Docs](https://github.com/cresset-tools/magequery)[ RSS](/packages/cresset-magequery/feed)WikiDiscussions Synced 1w ago

READMEChangelog (6)DependenciesVersions (22)Used By (0)

magequery
=========

[](#magequery)

magequery reads a Magento 2 codebase and tells you how it is wired: module load order, DI resolution (preferences, plugins, virtual types, constructor arguments), events, cron, routes, config across scopes, and the admin permission tree, among others. Every result cites the file and line it came from.

`bin/magento` and magerun boot the whole framework on every call, which takes one to three seconds. magequery parses the source XML and PHP directly and reimplements Magento's config-merge and DI rules, so it runs in milliseconds and works on a checkout that was never set up. It needs no database, no `setup:di:compile`, and no working PHP install.

```
$ magequery modules      # 88 modules, load order resolved
4 ms
$ magequery di Magento\Catalog\Api\ProductRepositoryInterface
19 ms
$ magequery doctor       # scan every config reference in the codebase
86 ms
```

Some commands can also read live data. Point them at the database from `env.php` (with `--db`, or as a dedicated live command) to read products, orders, indexer status, the scope tree, and similar runtime state. These commands report a clear error when the database is unreachable. The static commands never touch it.

Install
-------

[](#install)

```
# Linux and macOS
$ curl -LsSf https://bougie.tools/magequery.sh | sh

# Windows (PowerShell)
> irm https://bougie.tools/magequery.ps1 | iex
```

Prebuilt binaries (Linux gnu/musl, macOS arm64, Windows x64) are attached to every [GitHub Release](https://github.com/cresset-tools/magequery/releases) and mirrored to cresset infrastructure.

Or build from source. This needs a Rust toolchain, a C compiler, and CMake (the last two for the bundled MySQL client used by the live commands):

```
$ cargo install --git https://github.com/cresset-tools/magequery magequery
```

Point it at a store with `--root `, or run it from inside the Magento root (the default is the current directory).

Examples
--------

[](#examples)

`di` is the main command. It shows how the object manager assembles a type: the concrete class, the merged constructor arguments, and the plugin chain, each with its source.

```
$ magequery di Magento\Catalog\Api\ProductRepositoryInterface
Magento\Catalog\Api\ProductRepositoryInterface  (base)
  → Magento\Catalog\Model\ProductRepository   # vendor/.../module-catalog/etc/di.xml:11

arguments (1)
  collectionProcessor = \Magento\Catalog\Model\Api\SearchCriteria\ProductCollectionProcessor   # .../etc/di.xml:939

plugins (3)  run order
    0 remove_images_from_gallery_after_removing_product  [around delete]
    0 add_mutex_to_save_operation  [around save]
   10 configurableProductSaveOptions  [before save, after save]
```

`doctor` checks every merged config reference against what exists on disk. It reports broken references, cycles, and wiring that looks forgotten, and exits non-zero only on errors, so you can run it in CI.

```
$ magequery doctor
error  di argument $defaultHandler of Magento\Indexer\Model\HandlerPool injects missing
       class Magento\Indexer\Model\Handler\DefaultHandler   # .../module-indexer/etc/di.xml:30
error  preference for ...\ProductRenderSearchResultsInterface points at missing class
       ...\ProductRenderSearchResults   # .../module-catalog/etc/di.xml:54
warn   ...\CouponUsagesDecrement implements ObserverInterface but no events.xml registers it
```

`info` prints a one-screen summary of the install. It reads the static config and fills in live values from the database when it can reach one.

```
$ magequery info
magento       2.4.7  (magento/product-community-edition)
mode          developer
maintenance   off

base url      https://shop.example/
admin         https://shop.example/admin_XXXXXX/

frontend      Luma  (theme Magento/luma)
search        opensearch @ 127.0.0.1:9200

db            shop @ /run/mysqld/mysqld.sock
cache         default: redis db5 · page_cache: redis db5 · fpc: built-in · 14/14 types on
queue         amqp @ 127.0.0.1:5672

stores        1 website(s), 1 store(s), 1 store view(s)
modules       88 enabled, 0 disabled  (88 vendor, 0 app/code)
```

Notes
-----

[](#notes)

Every result ends with a `# file:line` comment. It is written as a trailing comment so a copied line stays valid, and it points at the source that produced the fact.

The static commands parse source files only. They do not read `var/cache` or `generated/`, so they work on a fresh checkout. Commands that can also use live data take `--db`; a few commands, such as `product`, `order`, and `stores`, read the database directly.

DI, plugins, events, and routes vary by area. By default these commands show a collapsed diff: the global base plus the per-area differences. `--area ` shows a single area, and `--all-areas` expands every area in full.

`--json` works on every command and is never colored. The single-value commands (`mode`, `base-url`, `maintenance`) print a bare value for use in scripts. Color is on when writing to a terminal, respects `NO_COLOR`, and can be set with `--color auto|always|never`.

Commands
--------

[](#commands)

Grouped as `magequery --help` shows them.

**Wiring** (the object manager): `di`, `preference`, `plugins`, `events`, `uses` (reverse DI).

**Entry points**: `routes`, `actions`, `webapi`, `cron`, `commands`, `graphql`.

**Data**: `schema`, `indexers`, `extension-attributes`, `catalog-attributes`, `eav`, `product`, `price`, `category`, `order`, `customer`, `quote`, `invoice`, `shipment`, `creditmemo`, `order-statuses`, `sequences`, `sales-rule`, `catalog-rule`, `tax`.

**Frontend**: `layout`, `widgets`, `email-templates`, `translations`, `ui-components`, `cms-page`, `cms-block`.

**Config and admin**: `config`, `system-config`, `acl`, `menu`, `admin-users`, `admin-roles`, `integrations`.

**Runtime** (from `env.php` and live connections): `db`, `redis`, `session`, `cache`, `lock`, `queue`, `url-rewrites`, `stores`.

**Project**: `info`, `mode`, `maintenance`, `base-url`, `admin-url`, `modules`, `deps`, `doctor`, `whatis`, `patches`.

The grammar is `magequery  [target] [flags]`. Run `magequery  --help` for the details of each.

Shell completions
-----------------

[](#shell-completions)

The `completions` subcommand prints a completion script to stdout. Add one line to your shell config:

```
# bash (~/.bashrc)
source
