PHPackages                             ineersa/call-graph - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. ineersa/call-graph

ActivePhpstan-extension[Debugging &amp; Profiling](/categories/debugging)

ineersa/call-graph
==================

PHPStan extension and DOT visualizer for application call graphs

v0.1.5(2mo ago)4181MITPHPPHP ^8.2

Since Apr 8Pushed 2mo agoCompare

[ Source](https://github.com/ineersa/call-graph)[ Packagist](https://packagist.org/packages/ineersa/call-graph)[ RSS](/packages/ineersa-call-graph/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (6)Dependencies (1)Versions (8)Used By (1)

Call Graph
==========

[](#call-graph)

`call-graph` is a PHPStan extension plus CLI tools for extracting and visualizing call graphs.

It writes `callgraph.json` during PHPStan analysis. You can open that in an **interactive HTML explorer** (no Graphviz required) or render **Graphviz DOT/SVG** for static diagrams and docs.

[![Call Graph Explorer: interactive graph with URL filters and node focus](docs/call-graph-explorer-2026-04-08.png)](docs/call-graph-explorer-2026-04-08.png)

Features
--------

[](#features)

- Extracts method calls (`$obj->method()`), static calls (`Class::method()`), and function calls (`foo()`).
- Uses PHPStan type/reflection data to resolve declaring classes where possible.
- Emits structured JSON with metadata (`file`, `line`, `callType`, `unresolved`).
- Includes compatibility output (`data`) for existing callmap-style tooling.
- **Interactive HTML** explorer (Cytoscape.js) with URL-driven filters and node focus—no Graphviz install needed.
- **Graphviz** DOT/SVG output with namespace clustering and regex filtering.
- Excludes function-involved edges by default in visualization (use `--include-functions` to opt in).
- Supports coupling-oriented views with namespace mode and edge-weight filtering.

Install
-------

[](#install)

```
composer require --dev ineersa/call-graph
```

Requirements: PHP 8.2+ and PHPStan 2.1+.

If you use `phpstan/extension-installer`, `callgraph.neon` is auto-registered from package metadata.

Without extension-installer, include it manually in your `phpstan.neon`:

```
includes:
    - vendor/ineersa/call-graph/callgraph.neon
```

Generate call graph JSON
------------------------

[](#generate-call-graph-json)

Run PHPStan with the extension config:

```
./vendor/bin/phpstan analyse -c vendor/ineersa/call-graph/callgraph.neon
```

By default this writes `callgraph.json` in the current working directory.

Override output location in your own config:

```
includes:
    - vendor/ineersa/call-graph/callgraph.neon

services:
    errorFormatter.callgraph:
        class: CallGraph\PHPStan\Formatter\CallGraphJsonFormatter
        arguments:
            outputFile: build/callgraph.json
```

Render visualization
--------------------

[](#render-visualization)

### Interactive HTML (recommended for exploration)

[](#interactive-html-recommended-for-exploration)

Loads the graph in the browser with pan/zoom, node focus, and shareable filter URLs. **Does not require Graphviz.**

```
./vendor/bin/callgraph-viz-html --input callgraph.json --html callgraph.html
```

Query parameters (changing them reloads the page):

- `mode=class|method|namespace`
- `namespaceDepth=`
- `minEdgeWeight=`
- `maxNodes=`
- `includeFunctions=1`
- `strictNamespaces=1` (when `ns` is set, keep only relations where both sides match)
- `ns=App\\Service,App\\Domain` (comma-separated namespace prefixes)

Example:

```
file:///.../callgraph.html?mode=method&ns=App\Service,App\Domain&maxNodes=300

```

### Graphviz (DOT and SVG)

[](#graphviz-dot-and-svg)

For static diagrams, documentation, or pipelines that already use `dot`:

```
./vendor/bin/callgraph-viz --input callgraph.json --dot callgraph.dot
./vendor/bin/callgraph-viz --input callgraph.json --dot callgraph.dot --svg callgraph.svg
```

Useful filters:

```
./vendor/bin/callgraph-viz \
  --mode method \
  --include '/^App\\/' \
  --exclude '/\\Tests\\/' \
  --max-nodes 250
```

Large graph / coupling-style view:

```
./vendor/bin/callgraph-viz \
  --mode namespace \
  --namespace-depth 3 \
  --min-edge-weight 2 \
  --max-nodes 120 \
  --include '/^App\\/' \
  --dot coupling.dot
```

Include functions if needed:

```
./vendor/bin/callgraph-viz --include-functions --mode method
```

Output format
-------------

[](#output-format)

`callgraph.json` contains:

- `meta`: generation metadata
- `edges`: full graph edges with enriched metadata
- `data`: callmap-compatible shape (`callingClass`, `callingMethod`, `calledClass`, `calledMethod`)

Example edge:

```
{
  "callerClass": "App\\Service\\UserService",
  "callerMember": "getUser",
  "callerKind": "method",
  "calleeClass": "App\\Repository\\UserRepository",
  "calleeMember": "find",
  "calleeKind": "method",
  "callType": "method",
  "file": "src/Service/UserService.php",
  "line": 41,
  "unresolved": false
}
```

Acknowledgements
----------------

[](#acknowledgements)

This project follows the PHPStan pattern for extracting structured data from analysis (collectors, a `CollectedDataNode` rule, and a custom error formatter), as described in [Using PHPStan to Extract Data About Your Codebase](https://phpstan.org/blog/using-phpstan-to-extract-data-about-your-codebase).

The callmap-compatible `data` shape and the overall idea of emitting a JSON call map from PHPStan build on prior work in [stella-maris/callmap](https://gitlab.com/stella-maris/callmap).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance85

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

6

Last Release

80d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86f5d21ab3c3ddca3f9af93bbcd79813a7db4eb17b179476538741519621ba7a?d=identicon)[ineersa](/maintainers/ineersa)

---

Top Contributors

[![ineersa](https://avatars.githubusercontent.com/u/4228843?v=4)](https://github.com/ineersa "ineersa (16 commits)")

### Embed Badge

![Health badge](/badges/ineersa-call-graph/health.svg)

```
[![Health](https://phpackages.com/badges/ineersa-call-graph/health.svg)](https://phpackages.com/packages/ineersa-call-graph)
```

###  Alternatives

[rector/rector

Instant Upgrade and Automated Refactoring of any PHP code

10.3k133.5M8.4k](/packages/rector-rector)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79173.3M2.0k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67070.7M1.3k](/packages/phpstan-phpstan-doctrine)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

4813.1M82](/packages/shipmonk-dead-code-detector)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.0M321](/packages/drupal-core-dev)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
