Download the PHP package degraciamathieu/php-dep without Composer
On this page you can find all versions of the php package degraciamathieu/php-dep. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download degraciamathieu/php-dep
More information about degraciamathieu/php-dep
Files in degraciamathieu/php-dep
Package php-dep
Short Description PHP dependency analyzer - extract and visualize class relationships
License MIT
Informations about the package php-dep
php-dep
PHP command-line dependency analyzer. Extracts and visualizes all class relationships in a project: inheritance, interfaces, traits, injections, instantiations, static calls, docblocks.
Installation
For global access:
Quick start
analyze command
<path> is optional, defaults to .
Options
| Option | Shortcut | Description |
|---|---|---|
--format=text\|json |
-f |
Output format (default: text) |
--class=FQCN |
-c |
Focus on a class (full FQCN) |
--sort=alpha\|deps\|fanin |
-s |
Table sort: alphabetical, number of outgoing dependencies, number of incoming dependencies (default: alpha) |
--limit=N |
-l |
Limit output to N classes |
--exclude=dir |
Exclude a directory (can be used multiple times) | |
--include-vendor |
Include the vendor/ directory in the analysis |
|
--skip-docblocks |
Ignore @param/@return/@throws annotations |
|
--quiet |
-q |
Suppresses the progress bar and warnings (stdout preserved) |
--verbose |
-v |
Show warning details |
Exit codes
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Parsing error(s) |
2 |
Internal error |
3 |
Invalid arguments |
Examples
Project overview
Displays a table with, for each class: type, number of outgoing dependencies (what it uses), incoming dependencies (what uses it), and source file.
Find the most coupled classes
Inspect a class
Displays two tables: what the class uses (outgoing dependencies) and who uses it (incoming dependencies), with the relationship type and source line.
JSON pipeline with jq
Exclude directories
Analysis without vendor
By default, vendor/ is excluded from the analysis but third-party classes appear as external nodes in the graph. No additional option is needed to ignore them entirely.
To analyze the vendor itself:
JSON output structure
Relationship types (edge.type)
Tier 1 — Maximum certainty (AST)
| Type | Description |
|---|---|
extends |
Class or interface inheritance |
implements |
Interface implementation |
uses_trait |
Trait usage |
param_type |
Type hint on a method parameter |
return_type |
Method return type |
property_type |
Class property type |
instantiates |
new Foo() |
static_call |
Foo::method() |
static_property |
Foo::$prop |
const_access |
Foo::CONST |
instanceof |
$x instanceof Foo |
catches |
catch (FooException $e) |
Tier 2 — High confidence (docblocks)
Extracted from @param, @return, @var, @throws. Confidence: high.
| Type | Source |
|---|---|
docblock_param |
@param FooType $x |
docblock_return |
@return FooType |
docblock_var |
@var FooType |
docblock_throws |
@throws FooException |
Confidence levels
| Value | Meaning |
|---|---|
certain |
Structural relationship guaranteed by the AST |
high |
Docblock, highly probable |
medium |
Ambiguous pattern (instanceof) |
low |
Dynamic pattern |
Warnings
| Type | Trigger |
|---|---|
dynamic_instantiation |
new $variable() — class unknown at static analysis time |
dynamic_call |
Unresolvable dynamic call |
parse_error |
Invalid or unreadable PHP file |
Warnings are printed to stderr. The JSON output includes them in warnings[]. With -v, the text output lists them at the end of the report.
How it works
- Discovery:
git ls-filesif inside a git repository, otherwiseRecursiveDirectoryIterator. Thevendor/,node_modules/, and.git/directories are excluded by default. - Parsing: nikic/PHP-Parser v5. The
NameResolverruns first in the traverser: all downstream names are resolved FQCNs. - Docblocks: phpstan/phpdoc-parser for
@param,@return,@var,@throws. - Memory: each file's AST is freed immediately after extraction (streaming). Only one AST in memory at a time.
- Vendor: in
boundarymode (default), vendor classes areexternalnodes (leaves) — their files are not analyzed.
Requirements
- PHP >= 8.2
- Composer
All versions of php-dep with dependencies
nikic/php-parser Version ^5.0
phpstan/phpdoc-parser Version ^1.0
symfony/console Version ^7.0