<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laboiteacode / filament-dependency-graph example snippets
use LaBoiteACode\DependencyGraph\DependencyGraphPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
DependencyGraphPlugin::make(),
]);
}
use Filament\Support\Enums\Width;
DependencyGraphPlugin::make()
->navigationLabel('Architecture')
->navigationIcon('heroicon-o-share')
->activeNavigationIcon('heroicon-s-share')
->navigationGroup('Developer tools') // string, enum or closure
->navigationSort(30)
->navigationParentItem('Tooling')
->navigationBadge(fn (): string => 'beta')
->registerNavigation(false) // keep the route, hide the menu entry
->slug('architecture-map')
->cluster(\App\Filament\Clusters\Developer::class)
->maxContentWidth(Width::SevenExtraLarge)
->canAccessUsing(fn (): bool => auth()->user()?->isDeveloper() ?? false);
use LaBoiteACode\DependencyGraph\Domain\Enums\GraphScope;
use LaBoiteACode\DependencyGraph\Domain\ValueObjects\GraphQuery;
use LaBoiteACode\DependencyGraph\Facades\DependencyGraph;
// Raw discovery snapshot: models, relations, Livewire components, panels,
// resources and warnings.
$snapshot = DependencyGraph::discover();
// Full graph with the default query.
$graph = DependencyGraph::graph();
// Focused sub-graph.
$graph = DependencyGraph::graph(new GraphQuery(
scope: GraphScope::Laravel,
panelIds: ['admin'],
focusNodeId: 'model:app.models.order',
depth: 2,
));
$graph->nodeCount();
$graph->edgeCount();
$graph->toArray();
// Exports.
$json = DependencyGraph::export('json');
$mermaid = DependencyGraph::export('mermaid');
DependencyGraph::clearCache();
use LaBoiteACode\DependencyGraph\Contracts\GraphExporter;
use LaBoiteACode\DependencyGraph\Domain\Graph\Graph;
use LaBoiteACode\DependencyGraph\Domain\ValueObjects\ExportOptions;
class GraphvizExporter implements GraphExporter
{
public function format(): string
{
return 'dot';
}
public function export(Graph $graph, ExportOptions $options): string
{
// Walk $graph->nodes and $graph->edges, return DOT markup.
}
}
DependencyGraphPlugin::make()
->registerExporter(new GraphvizExporter());
use LaBoiteACode\DependencyGraph\Contracts\NodeInspector;
DependencyGraphPlugin::make()
->registerInspector(new MyAuditableInspector());