SuperAPIAI Directory

phpgraph

github.com · AI coding

phpgraph is a PHP codebase knowledge graph tool for AI coding agents (such as Claude Code, Codex, Cursor), providing queries via the MCP protocol. It performs static analysis only, uses no LLM, does not access the network, and does not run code; code never leaves the local machine. It can parse a project and build a call relationship graph, answering questions like "what will be affected by changing a certain method", including call chains formed through interfaces, service containers, message buses, and routes that are hard to find with grep. Every conclusion is labeled with a confidence level (EXTRACTED, INFERRED, AMBIGUOUS), and parts that cannot be linked are also reported.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS · Linux

About this tool

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:

  1. 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.
  2. 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.
  3. 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.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools