Download the PHP package maarheeze/codegraph without Composer
On this page you can find all versions of the php package maarheeze/codegraph. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maarheeze/codegraph
More information about maarheeze/codegraph
Files in maarheeze/codegraph
Package codegraph
Short Description local php code indexing for ai assistants
License MIT
Informations about the package codegraph
CodeGraph
Make AI agents faster and cheaper to use on your codebase.
CodeGraph indexes your PHP code structure (classes, methods, functions, and relationships) and stores it locally. AI agents query this index instead of reading files.
Inspired by colbymchenry/codegraph and kha333n/laravel-code-graph
Result:
- ⚡ Faster — Queries in milliseconds instead of reading files
- 💰 Cheaper — Use fewer tokens, no need to pass file contents
- 🔍 Accurate — Structured data about code relationships, not guesses
Ask your AI agent questions directly:
- "Who calls this method?"
- "What breaks if I change this class?"
- "Show me all usages of this function"
- "What's the impact radius of this change?"
How It Works
- Index your code —
php vendor/bin/codegraph index(one-time) - AI agent uses it — Register CodeGraph as an MCP server (works with Claude Code and any MCP-compatible AI)
- Faster context — AI queries the index instead of reading files
Works with Claude Code, Cursor, and any AI supporting MCP protocol.
Installation
That's it. CodeGraph will:
- Create a
.codegraph/directory with SQLite database (should be ignored by git!) - Scan your code (
app/andsrc/directories by default) - Extract symbols, relationships, and code structure
- Build the index
Optional: Auto-reindex on changes
For continuous development, keep CodeGraph in sync automatically:
This watches your code for changes and reindexes automatically. Press Ctrl+C to stop. To automatically initialize and index your codebase after dependencies are installed or updated, add the following to your composer.json:
Verify it worked:
This shows how many symbols, edges, and files were indexed.
Usage
CLI Search
Claude Code Integration
CodeGraph works with Claude Code via the MCP protocol.
Automatic Setup (Recommended)
Running php vendor/bin/codegraph init automatically:
- Creates
.codegraph/directory and SQLite database - Detects your environment (Sail, Docker, or plain PHP)
- Configures
.mcp.jsonwith the correct MCP command - Adds CodeGraph guidelines to your
CLAUDE.md
That's it! Claude Code will automatically discover and use CodeGraph's tools.
Manual Setup (if needed)
If you need to manually configure .mcp.json:
Replace vendor/bin/sail with:
phpfor plain PHP projectsdockerwith args["compose", "exec", "-it", "app", "php", "vendor/bin/codegraph", "mcp"]for Docker Compose (replaceappwith your actual service name)
Then ask Claude Code:
- "Search for the User model"
- "Who calls the create method on User?"
- "What breaks if I change this service?"
- "Find all usages of the payment provider"
Available tools:
codegraph_search— Find symbols by name or FQNcodegraph_callers— Who calls a symbolcodegraph_callees— What a symbol callscodegraph_blast_radius— Impact of changing a symbolcodegraph_search_chunks— Full-text search across code
Commands
init — Initialize CodeGraph in your project
Optional: Explicitly set MCP configuration (auto-detected by default):
If not specified, CodeGraph auto-detects your environment:
- Checks for
vendor/bin/sail→ uses Sail - Checks for
docker-compose.yml→ uses Docker - Falls back to plain PHP otherwise
index — Index your code (tracks changes, only re-parses what changed)
watch — Auto-reindex when files change (useful during development)
status — See indexing statistics
mcp — Start MCP server (for Claude Code integration)
search — CLI symbol search
Configuration
Customize scan paths
Default: src/ and app/
Customize excludes
Default: vendor/, node_modules/, storage/
Re-index your code
CodeGraph tracks file hashes and only re-parses changed files:
To force full re-index:
What Gets Indexed
Symbols: Classes, interfaces, traits, enums, methods, functions, properties
Relationships: Method calls, function calls, constructors, inheritance (extends/implements/uses), parent calls
Metadata: File paths, line numbers, visibility (public/protected/private), static/abstract markers, method signatures
Known Limitations
- Dynamic class names (
new $className()) are not resolved - Variable method calls (
$obj->$method()) are not detected - Closures and callbacks are not indexed
- External/vendor code (Composer packages) is not indexed
- Template files (Blade, Twig, etc.) are not analyzed
- Service container resolution is not automatic
Roadmap
- [ ] 100% code coverage — Comprehensive unit and integration tests
- [ ] Index template files — Support for Blade, Twig or HTML templates (core package or plugin TBD)
- [ ] Extensive documentation — Architecture guides, API reference, plugin development docs
Incremental Sync
CodeGraph uses file hashing to detect changes:
Only files that changed since last index are re-parsed. This makes indexing fast on large codebases.
To see what changed:
API Usage (PHP)
Database Schema
CodeGraph uses SQLite with the following tables:
symbols— All indexed symbols (classes, methods, functions, etc.)edges— Relationships between symbols (calls, inheritance, etc.)chunks— Code snippets indexed for full-text searchfiles— File metadata (paths, hashes, timestamps)
Direct database queries are supported for custom analysis.
License
MIT
All versions of codegraph with dependencies
ext-json Version *
ext-pdo Version *
ext-pdo_sqlite Version *
nikic/php-parser Version ^5.0
symfony/finder Version ^8.0
symfony/console Version ^8.0
webmozart/assert Version ^2.3