Download the PHP package kha333n/laravel-code-graph without Composer

On this page you can find all versions of the php package kha333n/laravel-code-graph. 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 laravel-code-graph

Laravel Code Graph

A persistent, structural map of your Laravel codebase, exposed to AI assistants over MCP — so they get token-efficient, accurate context instead of re-reading whole files.

PHP Version Laravel


By the AI, For the AI

Only AI and God knows how it works, but it works.

As per the rule of ✨

Why this exists

When you ask an AI assistant (Claude Code, Cursor, Windsurf, Zed, Continue) to make a change in a Laravel project, it typically does this on every turn:

  1. grep for the symbol you mentioned
  2. Read whole files to understand the context
  3. Read more whole files to find the callers
  4. Read the tests for those files
  5. ...and only then start editing

That's a lot of tokens spent re-discovering structure that doesn't change between turns. On a real Laravel codebase it adds up to half or more of every conversation.

Laravel Code Graph parses your project once into a local SQLite graph, keeps it up to date incrementally on every file change, and exposes it to AI assistants via the Model Context Protocol. Instead of grepping and reading whole files, the assistant asks the graph "where is ScoringService::score?" and gets back:

Then it can Read exactly those 16 lines instead of the whole 800-line file.

What it indexes

A single SQLite file in .code-graph/index.sqlite containing:

Symbols

Edges (directed relationships)

Chunks

Installation

Requires PHP 8.3+, Laravel 11 / 12 / 13, and the pdo_sqlite extension.

The package auto-discovers via Laravel's package discovery — no service provider registration needed.

Quickstart

That's it. The install command:

  1. Publishes config/code-graph.php to your project
  2. Builds the initial graph
  3. Registers code-graph in your project's .mcp.json so AI clients can connect (auto-detects Windows + WSL vs native)

After the install you'll see something like:

The index lives at .code-graph/index.sqlite — add .code-graph/ to your .gitignore.

Subsequent runs only re-parse files that actually changed:

Connecting to your AI assistant

code-graph:install does this automatically — it writes a code-graph entry into your project's .mcp.json (or creates the file if it doesn't exist) and auto-detects whether you're on a native Linux/macOS install or inside WSL on Windows. The resulting entry looks like one of:

After installing, restart your AI assistant (Claude Code, Cursor, Zed, ...) so it picks up the new MCP server. Verify with the MCP Inspector if needed:

If you need to register or re-register the MCP server later (or remove it):

Existing entries for other servers (like laravel-boost) are preserved.

The graph auto-refreshes on every tool call (mtime fast path keeps it under a few milliseconds), so the assistant always sees fresh data even right after you save a file.

The MCP tools

Every tool returns exact file:start-end line ranges so the calling assistant can Read only the slice it needs.

find-symbol-tool

Look up a symbol by name or fully qualified name. Falls back to FTS5 prefix matching if there's no exact hit. By default, also returns the file's use statements so you can author a new file from the same template without an extra Read.

search-code-tool

Keyword and intent search across symbol-level chunks (method bodies, small classes, Blade views) ranked by BM25. Use this when you don't know the exact name but you know what you're looking for.

get-callers-tool

Find every callsite that calls a function, method, or constructor. Pass a class FQN to get callers of any method on that class, or a method FQN for the exact callers.

Method calls on dynamic receivers (when the static type isn't resolvable) are recorded with a wildcard receiver ?::methodName.

get-callees-tool

The inverse: what does this function/method/class call?

get-blast-radius-tool

Recursive BFS over the call graph going backwards from a root symbol — every caller, every caller's caller, up to the requested depth. Use this before changing a method to see what might break.

Results are depth-stratified so you can see which symbols are most directly affected.

get-relations-tool

List Eloquent relations (hasMany, belongsTo, morphMany, etc.) declared on a Model. Returns the relation type, the related model FQN, and the file/line where each relation lives.

get-implementations-tool

Find every concrete class that extends, implements, or uses a given class, interface, or trait. The inverse of get-callers for inheritance.

report-issue-tool (opt-in)

Lets the AI assistant log a case where one of the other tools gave a wrong, missing, incomplete, or misleading result. The package writes the entry to a local markdown file (.code-graph/feedback.md by default). Disabled by default — enable it in config/code-graph.php if you want to gather a feedback log over time. Local-only; nothing is sent over the network.

Commands

Command Description
php artisan code-graph:install Full setup: publish config, run the first build, and register the MCP server in .mcp.json. Pass --force to overwrite an existing config or --skip-mcp to keep .mcp.json untouched.
php artisan code-graph:install-mcp Just the .mcp.json step — register, update, or --remove the code-graph server entry. Auto-detects Windows/WSL vs native.
php artisan code-graph:build Re-index the project. Pass --fresh to nuke the existing graph and rebuild from scratch.
php artisan code-graph:watch Long-running incremental indexer for active development. Polls on a 1-second interval; the mtime+size fast path keeps each tick negligible.
php artisan code-graph:wire-claude-md Insert (or update) an instructions block in your project's CLAUDE.md so AI assistants know to prefer code-graph tools over grep/Read. Idempotent. Pass --remove to take it out again.
php artisan mcp:start code-graph Start the local MCP server. Used by AI clients via stdio — you don't normally run this by hand.
php artisan mcp:inspector code-graph Launch the MCP Inspector for interactive testing of the tools.

Configuration

The published config lives at config/code-graph.php:

You can override the database location with the CODE_GRAPH_DB env var if you want the index somewhere other than .code-graph/. Set CODE_GRAPH_FEEDBACK=true to enable the feedback log.

How it works

Indexing pipeline

  1. Walk the configured scan_paths with Symfony Finder.
  2. For each file: mtime + size fast path — if both match the stored values, skip without reading.
  3. On a mismatch: read + SHA-256. If the hash matches, just update mtime/size and skip.
  4. Otherwise parse with nikic/php-parser and run a pipeline of small extractors over a single AST traversal:
    • SymbolVisitor — class/interface/trait/enum/method/function nodes
    • InheritanceEdgeVisitor — extends, implements, uses_trait
    • CallEdgeVisitor — calls, instantiations, constructor DI
    • EloquentRelationVisitor — hasMany/belongsTo/etc.
    • ServiceProviderBindingVisitor — bind/singleton/scoped/instance
    • AsActionRewriter — detects the AsAction trait and rewrites Foo::run/dispatch/... calls into edges targeting Foo::handle
    • FilamentResourceVisitor — protected static $model = X::class
    • RouteVisitor — Route::get/post/... in routes/*.php
    • MigrationVisitor — Schema::create/table in database/migrations/
    • ChunkExtractor — slices symbol bodies for full-text search
  5. Blade files (.blade.php) are handled by a separate extractor that uses regex over the raw text — Blade isn't valid PHP, so nikic's parser doesn't apply.
  6. Persist (file row, symbols, edges, chunks) to SQLite atomically per file.
  7. After every file is processed, run a single resolveEdges() pass that joins source/destination FQNs against symbols.fqn to fill in numeric symbol IDs — this lets a visitor in file A emit an edge to a symbol that lives in file B without waiting for B to be parsed.

Storage

Five tables in a single .code-graph/index.sqlite file:

Table Purpose
files One row per indexed file with sha256 + size + mtime, for incremental change detection
symbols Class/interface/trait/enum/method/function nodes
edges Directed relationships between symbols, with optional resolved symbol IDs
chunks Symbol bodies for the search layer
symbols_fts / chunks_fts FTS5 mirrors for fast text search

Freshness

The package guarantees that AI tools always see fresh data:

Why this saves tokens

Working with Laravel Boost

If you use Laravel Boost (the official Laravel MCP server), the two are complementary, not overlapping:

Layer Source of truth Tool
Versioned package docs (Laravel, Livewire, Filament, Pest, Spatie...) composer.lock Boost search-docs
Runtime (DB schema, last error, logs, browser logs) Live app Boost database-*, last-error, browser-logs
Code structure (symbols, edges, blast radius, callers, search) Your codebase laravel-code-graph

Boost owns docs and runtime. laravel-code-graph owns structure. Run both side-by-side in your .mcp.json and your AI assistant gets the full picture.

Contributing

Issues and pull requests are welcome on GitHub. Before opening a PR, please open an issue first to discuss the change — especially if you're touching the storage schema or the MCP tool surface.

To work on the package locally:

The test suite uses orchestra/testbench to boot a minimal Laravel app and exercises the indexer end-to-end against fixture files in a temp directory.

License

MIT. See LICENSE.


All versions of laravel-code-graph with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-pdo_sqlite Version *
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
laravel/mcp Version >=0.1 <1.0
nikic/php-parser Version ^5.0
symfony/finder Version ^7.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 kha333n/laravel-code-graph contains the following files

Loading the files please wait ...