Skip to content

Export the module graph

php artisan larch:graph exports the graph of modules from the running app. Package discovery registers the command.

Terminal window
php artisan larch:graph --html

Larch writes larch-graph.html at the project root. Open it in a browser. It needs no network. The report draws the modules and their links, turns each kind of link on and off, and lists every link and unknown link.

To write it somewhere else:

Terminal window
php artisan larch:graph --html --output=build/graph.html
Terminal window
php artisan larch:graph --json > graph.json

JSON is the default, so --json is optional. Mortise reads this format. The fields are in the graph format reference.

Artisan does not read tests/Pest.php. Give the configuration as options when it is not the default:

Terminal window
php artisan larch:graph \
--modules='App\Modules\*' \
--paths=app --paths=Modules \
--public-api=Contracts --public-api=Events

To skip booting the app and read imports only:

Terminal window
php artisan larch:graph --imports-only

Unknown links, such as app($class) or a binding closure with no return type, are in the unknown list of the JSON and in the report. To make Larch follow a binding, see Let Larch follow your bindings.