Download the PHP package quitscope/laravel-flow-tracer without Composer
On this page you can find all versions of the php package quitscope/laravel-flow-tracer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download quitscope/laravel-flow-tracer
More information about quitscope/laravel-flow-tracer
Files in quitscope/laravel-flow-tracer
Package laravel-flow-tracer
Short Description Trace Laravel request flows and export Graphviz diagrams from routes, controller actions, services, and models.
License MIT
Homepage https://github.com/quitscope/laravel-flow-tracer
Informations about the package laravel-flow-tracer
Laravel Flow Tracer
An Artisan command that shows what happens behind a route: which middleware runs, which controller method handles it, and which services and models that method touches. You get the result as a table, as JSON, or as a diagram.
I built it because I kept opening five files just to answer "what does this endpoint actually do?" in larger projects. Now it's one command.
Requirements
- PHP 8.1+
- Laravel 10, 11 or 12
- Graphviz for PNG, SVG and DOT output. Table, JSON and Mermaid work without it.
Installation
The service provider is registered through package discovery.
Graphviz, if you want images:
Check it with dot -V. On Windows the package looks for C:\Program Files\Graphviz\bin\dot.exe, everywhere else it calls dot from your PATH. If yours lives somewhere else, publish the config and set graphviz.dot_path.
Usage
Pick a starting point:
By default this prints the tables and writes a PNG to storage/app/flow-diagrams. Skip the image with --no-png.
Some more examples:
The Mermaid output for the screenshot above is in docs/examples/flow-example.mmd. GitHub renders it if you put it in a mermaid code block.
All options
| Option | What it does |
|---|---|
--route= |
Trace a named route |
--url= |
Trace a URL path (tries GET, POST, PUT, PATCH, DELETE) |
--action= |
Trace Class@method, or an invokable class |
--format= |
table (default) or json |
--no-png |
Don't write the default PNG |
--output= |
Path for the default PNG |
--export= |
Extra output: png, svg, dot or mermaid |
--forward |
Classes the controller depends on |
--backward |
Classes that depend on the controller |
--impact |
Dependency counts and a risk level |
--circular |
Look for circular dependencies |
--depth=3 |
Depth for --forward / --backward |
--internal |
Show internal method calls of the controller method |
--show-params |
Include parameters (with --internal) |
--deep |
Keep following detected classes |
--max-deep=10 |
Limit for --deep |
--stats |
Count controllers, services, models and actions |
--scan= |
Directory for --stats (defaults to the project root) |
--debug-connections |
Print what --deep detects and why |
Configuration
The settings that matter:
| Key | Default |
|---|---|
output_directory |
storage_path('app/flow-diagrams') |
graphviz.dot_path |
null (auto) |
graphviz.dpi |
300 |
graphviz.size |
null |
How it works (and where it falls short)
The route part comes straight from Laravel's router, so route, middleware and controller are exact. Everything below the controller is found by reading the source of the controller method: constructor dependencies, new SomethingService(), SomethingAction::run(), Model::find() and so on. Classes are recognised by name suffixes like Service, Action, Query, Repository and Handler.
So this is a static, best-effort view. Calls behind facades, container lookups or dynamic method names won't show up, and classes that don't follow those naming conventions can be missed. For getting an overview of an unfamiliar codebase it has been good enough for me. Issues and PRs for better detection are welcome.
Troubleshooting
Image export fails with "cannot find the path" or "dot: command not found"
Graphviz isn't installed or not where the package expects it. Set graphviz.dot_path, or use --no-png.
"Route ... not found"
--route wants the route name, not the URI. Use --url for paths. php artisan route:list shows both.
Out of memory on big projects
php -d memory_limit=512M artisan flow:trace ...
Tests
License
MIT, see LICENSE.md.
All versions of laravel-flow-tracer with dependencies
illuminate/console Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
symfony/finder Version ^6.0|^7.0
symfony/process Version ^6.0|^7.0