graphp/graph
Graphp/graph is a PHP graph data structure library for building and traversing graphs of vertices and edges. Create directed or undirected graphs, attach attributes, and run common algorithms like shortest paths, cycles, and connectivity for analysis and visualization.
Strengths:
Weaknesses:
Key Use Cases (Unchanged):
Laravel Compatibility:
create_function with closures, add type hints).config/app.php:
'bindings' => [
Graph::class => fn() => new Graph(),
],
Testing:
amphp/graph or Neo4j’s PHP client.| Risk Area | Severity | Mitigation Strategy | Update from Prior Assessment |
|---|---|---|---|
| PHP 8.2+ Incompatibility | High | Fork and backport; use rector for upgrades. |
New: PHP 8.1 support added, but 8.2+ still unsupported. |
| Memory Leaks | Medium | Profile with Xdebug; implement lazy loading. | Unchanged. |
| Lack of Laravel Hooks | Medium | Create decorators for Eloquent events. | Unchanged. |
| No Type Safety | Low | Add PHP 8.1 type hints via traits. | New: String vertex ID fix reduces some edge cases. |
| Community Support | High | Engage GitHub issues; consider paid support. | New: CI pipeline improves transparency. |
pg_graph or Neo4j.graphp/graph (PHP 8.2+ compatible) or amphp/graph been ruled out?class LaravelGraphService {
public function __construct(private Graph $graph) {}
public function buildFromModels(string $modelClass, string $relation): Graph {
$models = $modelClass::with($relation)->get();
// Convert models to graph nodes/edges...
return $this->graph;
}
}
Schema::create('graph_edges', function (Blueprint $table) {
$table->id();
$table->string('source_id'); // Store model UUIDs
$table->string('target_id');
$table->decimal('weight', 8, 2)->default(1);
$table->timestamps();
});
$path = Cache::remember(
"graph_path_{$source}_{$target}",
now()->addMinutes(5),
fn() => $this->graphService->shortestPath($source, $target)
);
php-cs-fixer and rector to prepare for PHP 8.2+.create_function with closures.strict_types=1 and type hints for methods.- $callback = create_function('$a, $b', 'return $a->weight <=> $b->weight;');
+ $callback = fn($a, $b) => $a->weight <=> $b->weight;
HttpFoundation).composer.json (PHP 8.1 target).memory_limit; use PostgreSQL pg_graph for persistence.| Failure Scenario | Impact | Mitigation | Update |
|---|---|---|---|
| **PHP 8.2 |
How can I help you explore Laravel packages today?