Download the PHP package b10k/craft-component-map without Composer

On this page you can find all versions of the php package b10k/craft-component-map. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package craft-component-map

Component Map

Which template renders the Hero block? What else breaks if I change _components/button.twig? In a Craft project the answer is spread over Twig includes, a dispatcher that picks a template by block.type.handle, and the content model in the control panel. Component Map puts it in one place — for you, and for the coding agent that is about to edit your templates.

It answers “where is this used?” and “what does this change affect?” from the command line, as text or JSON — built from your templates as they are right now, on every call. It runs where you develop: nothing is generated into the repository, so there is no map to commit, keep up to date or merge.

Free (MIT). Craft CMS 5, for local development and staging.


What it maps

What it cannot resolve (an include of a bare variable, a missing template) is listed under Not resolved, not silently dropped.

Requirements

Craft CMS 5, PHP 8.2+. Nothing else — no Node.

Installation

Read-only: it reads templates, the content model and which entries contain which blocks (canonical content only — no drafts or revisions; turn it off with readEntries), and writes only to storage/ (and to AGENTS.md when you ask it to). It works from the console and, on Craft 5.12+, as read-only tools on Craft's MCP server — both meant for where you and your coding agent edit templates: local development and staging. On an environment with allowAdminChanges off (production, as a rule) Component Map offers nothing on the MCP server.

Commands

Command What it does
component-map/show <query> Where a template, entry type, section or Matrix field is used, what it uses, and for a block the entries it is on. <query> can be _blocks/hero, templates/_blocks/hero.twig, hero (entry type) or home (section). --json.
component-map/impact <files> What changing these files affects: templates above them, blocks rendered through them, pages that reach them. --git uses your uncommitted changes; --since=main everything that changed on your branch, committed or not. --json.
component-map/unused What nothing uses: blocks no entry contains, templates nothing reaches, entry types and Matrix fields attached nowhere. --json.
component-map/build The whole map: --stdout prints it as Markdown, --json as a graph. Without either, writes both to storage/component-map/ (a local snapshot, not for committing).
component-map/agents Prints the note that points a coding agent to these commands; --file=AGENTS.md (or CLAUDE.md) adds it to that file, or updates it.

show and impact read the templates on every call — there is nothing to rebuild first.

Exit codes: 0 ok · 1 not found · 2 could not run.

Impact

Entries to check are the pages to open: every entry that contains an affected block (however deeply nested), and every entry of a section whose page template, layout or a component they include changed. Entries that are not live say so (disabled, pending, expired). --limit=0 lists all.

A block is affected when a changed file is on its render path: its adapter, anything the adapter includes, and the dispatcher, page templates and layouts above it. So changing a card component affects Cards Grid, not Hero — and changing the layout affects every block.

Changes to the content model count too. A project config file such as config/project/entryTypes/card--….yaml is read as “entry type Card changed”: it affects the Card block, the Cards Grid it sits in, and the pages that show them. The same goes for Matrix fields, sections and category groups — the link between content and templates is what the map is for. Templates left out by the ignore setting (Component Guide stories) are listed separately.

Before you open a pull request, check the whole branch — what you committed and what you have not yet:

It compares with the point where your branch left main, so work merged into main since then is not counted. A deleted template is reported as deleted, and counts through the templates that still reference it: they now break. The list of blocks and pages is what to check in the browser.

Unused

A template is reached from a section's page template, from any template Craft serves by URL (no path segment starting with _), or from an entry point, and through everything those include, embed, extend or import. A template used only by other unreached templates is unreached too, so a dead chain shows up whole.

Treat it as a list of candidates, not a delete list. A template rendered from PHP, config/routes.php or a plugin setting is invisible to the map — once you have checked one, add it to entryPoints (the template above is Component Guide's preview frame, rendered by that plugin). And if a reached template includes something chosen at runtime ({% include someVariable %}), the report says so: anything it lists might be used through that.

With Component Check

Component Map is useful on its own. If you also use Component Check, which tests blocks in a browser by entry type handle, impact prints the command to test exactly the affected blocks, and you can chain them:

For coding agents

The map is not a file in your repository, so an agent will not find it by searching. Tell it once:

That adds a short note — between <!-- component-map --> markers, so running it again updates it instead of adding a second copy — telling the agent to run show before editing a template and impact --git after. It uses ddev craft when the project runs in DDEV. The note does not change when your templates do, so it is safe to commit. The full instructions are in AGENTS.md in this package.

On Craft's MCP server (Craft 5.12+)

Craft 5.12 ships an MCP server, so an agent connected to your site can use the map without a terminal. Component Map adds:

Tool What it returns
component-map.overview Each section's page template, the dispatchers that render page-builder blocks, the template each block type is rendered by and how many entries use it, and what the map cannot follow. A good first call.
component-map.show One template, block, section or Matrix field — as show --json.
component-map.impact What changing these files affects, with the entries to check — as impact --json. files, or git: true, or since: "main" (the last two need a git checkout where Craft runs).
component-map.unused As unused --json.

All read only (readOnlyHint, so the mcp:read scope is enough), for users with control-panel access. Entries a user may not view are counted, not listed. The map is built afresh on every call, so a long-running stdio server never answers from yesterday's templates.

It also adds two checks to content-model.audit — only the certain cases:

And a few lines to info.get: this project's dispatchers and which tool to use when, so an agent knows the convention before it opens a template.

Only where allowAdminChanges is on, and the mcp setting can switch it all off. If a later Craft changes what the MCP attributes accept, Component Map leaves its tools out and logs a warning — the rest of the site's MCP server keeps answering.

Configuration

config/component-map.php:

Setting Default
markdownFile @storage/component-map/COMPONENT-MAP.md Where build writes Markdown. Empty = do not write it
jsonFile @storage/component-map/graph.json Where build writes JSON. Empty = do not write it
readEntries true List the entries that contain affected blocks. false = templates and schema only
entryPoints [] Globs of templates rendered from outside Twig (PHP, routes, plugins), so unused does not report them, e.g. ['_emails/*']
mcp true Tools, audit checks and instructions on Craft's MCP server (Craft 5.12+) — only where allowAdminChanges is on. false = none
ignore ['*.stories.twig'] Glob patterns (relative to templates/) to leave out

Limitations

Development

The scanner, resolver, graph, impact analysis and Markdown writer are Craft-free and unit-tested against a fixture site.

License

MIT


All versions of craft-component-map with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
craftcms/cms Version ^5.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package b10k/craft-component-map contains the following files

Loading the files please wait ...