Purpose: phpgraph provides AI coding agents with a knowledge graph of a PHP codebase, letting agents obtain cross-file, cross-abstraction dependency relationships in a single call via the MCP protocol, instead of guessing file by file with grep.
Main capabilities:
- impact_of: lists all dependents affected by a change to a method, ordered from nearest to farthest, including callers through implemented interfaces, reachable routes, and tests that need to be run.
- outline: gives classes, the routes that enter them, behavior in method bodies, wiring relationships, and tests in one go, helping agents read only files whose logic is not obvious.
- Message and route linking: connects senders, messages, and handlers for Symfony Messenger, Laravel, Ecotone, PrestaShop, WordPress hooks, and custom buses; links routes with controllers and HTTP calls with reachable routes.
- Receiver type inference: inferred from return types, docblocks, generics, branches, and vendor/ signatures, with support for PHP 4 and 5 syntax.
- Confidence labeling: every fact is marked EXTRACTED, INFERRED, or AMBIGUOUS, and anything that cannot be linked is reported.
Usage:
- Install the executable (Linux, macOS, bundled PHP): the install script verifies SHA-256 and installs to ~/.local/bin. For Windows, Composer, PHAR, and Docker methods, see docs/INSTALL.md.
- Connect Claude Code: run the configuration command in the project directory; it outputs the claude mcp add phpgraph -- ... command, a shareable .mcp.json, and a prompt line written to CLAUDE.md, recommending that agents call phpgraph before grep. MCP clients such as Codex, Cursor, and Sherpa can use phpgraph mcp-config codex|cursor|sherpa|json.
- Ask questions: the graph is built on the first call and then kept up to date as you edit.
Use cases: impact analysis, feature understanding, locating message handlers and routes, and caller tracing in large or legacy PHP codebases. In benchmarks, on Akeneo PIM (8,416 PHP files), median token consumption for the same answers was reduced by 35%; however, on 6 impact tasks, version 2.2.0 had higher accuracy (17/18 vs. 15/18) but used 9.8% more total tokens (from −30% to +36% per task), with no improvement in elapsed time and considerable run-to-run variance.
Limitations: it is not a runtime tool; it only reads code and configuration and does not execute. Services built at runtime (compiler passes, ids computed at runtime) and dynamic calls ($this->$name(), __call without @method) cannot be resolved. It recognizes only Symfony, Laravel, Ecotone, PrestaShop, and WordPress conventions plus generic conventions (handler attributes, *Handler, *Bus); other frameworks get only the call graph; only PHP files are read. When dependencies are not installed, call chains break at the first dependency, so having vendor/ is recommended. The analyzed project can be any PHP version (including PHP 4 syntax) without needing its PHP installed; phpgraph itself as an executable or Docker requires no PHP, while using Composer or PHAR requires PHP 8.5 or newer.