spatie/php-type-graph
Build a graph of all PHP types in your project. Analyze classes, interfaces, enums, and their relationships to understand your codebase structure, dependencies, and type usage. Useful for architecture insights, tooling, and visualization (WIP).
The spatie/php-type-graph package is a type introspection tool designed to generate a graph of all types (classes, interfaces, traits, enums, etc.) within a PHP/Laravel project. While its primary use case is static analysis (e.g., dependency mapping, type hierarchy visualization), it may not directly integrate into core application logic. However, it could be leveraged for:
Key Limitation: The package is archived and labeled as a "work in progress," meaning its API may evolve unpredictably. This introduces high technical risk for production adoption unless treated as a temporary or experimental tool.
phpstan, psalm, or phpdocumentor offer similar (or better) type analysis with more stability.composer test or a custom GitHub Action.symfony/dependency-injection + custom traversal.phpstan (with --generate-report) or psalm.graphviz + custom PHP scripts.composer require spatie/php-type-graph --dev).use Spatie\TypeGraph\TypeGraph;
$graph = new TypeGraph();
$graph->generate(); // Outputs graph data
composer.json scripts:
"scripts": {
"post-autoload-dump": "php vendor/bin/type-graph generate --format=json > type-graph.json"
}
php artisan type:graph --format=dot --output=graph.dot
storage/).symfony/console for CLI).eval or create_function).How can I help you explore Laravel packages today?