- What is clue/graph and what can I use it for in Laravel?
- clue/graph is a lightweight, framework-agnostic PHP library for modeling directed, undirected, and multigraph structures with vertices, edges, and attributes. In a Laravel app it works best as an in-memory computational kernel for bounded problems such as dependency or DAG validation, shortest-path pricing over a small network, workflow reachability, permission-inheritance resolution, or traversal of a pre-filtered node set. It is not a replacement for recursive CTEs, join tables, or a graph database when querying large persisted relationship sets.
- How do I install clue/graph in a Laravel project?
- Run composer require clue/graph; there is no service provider, facade, config file, or migration to publish. Composer autoloading makes the classes available directly in your services, actions, and queued jobs. You can test it like any plain PHP dependency, ideally behind your own small adapter interface.
- Does clue/graph provide a Laravel service provider or facade?
- No. clue/graph is framework-agnostic and ships no Laravel-specific integration, so there is nothing to register in config/app.php or a bootstrap file. You instantiate its Vertex, Edge, and graph classes directly from your domain layer. Treat it as a library, not a Laravel package.
- Which Laravel and PHP versions are supported by clue/graph?
- The last tagged release is from 2021-12-30, so there is no official PHP 8.x or Laravel 11 validation signal. The concrete risk is Composer constraints: the package may pin older PHP ranges and block or complicate framework upgrades even if the code itself runs. Check its composer.json against your platform requirements before adoption and test upgrades without --ignore-platform-reqs.
- How do I build a clue/graph graph from Eloquent models?
- Write an adapter or mapper layer: query the models or rows you need, create a Vertex per item with its ID and relevant attributes, add Edges for each relationship, then run the algorithm. Map the results back to Eloquent IDs or DTOs at the boundary. That mapping layer, not the Composer install, is the real integration work and the main long-term maintenance cost.
- What graph algorithms does clue/graph support?
- It provides classic traversal and shortest-path algorithms including Dijkstra, Moore-Bellman-Ford, and topological sorting, plus directed, undirected, and multigraph structures. It supports weighted edges, loops, parallel edges, and vertex or edge attributes. Confirm the exact algorithm set you need against the package source before committing.
- Can clue/graph handle large graphs in a Laravel production app?
- It is an in-memory library that creates objects per vertex and edge, typically backed by SplObjectStorage, so memory and runtime scale poorly past tens of thousands of nodes and edges. Building the graph on every request adds pure overhead. Use it for bounded, transient computations in a service or worker, not for per-request analysis of a large persisted dataset.
- What happens if I use negative edge weights with clue/graph?
- Dijkstra assumes non-negative weights, and negative inputs can produce silently wrong shortest-path answers rather than an error. Your application should own validation that rejects negative weights for Dijkstra or routes those cases to a suitable algorithm. You also need explicit decisions for floating-point weight comparisons and tie-breaking.
- Is clue/graph actively maintained?
- The last tagged release is 2021-12-30, roughly three-plus years without a release, and the project is community-supported MIT software with no vendor SLA. The metadata lists the repository as unknown, so verify source provenance, test coverage, issue history, and security response before adoption. Treat it as adopt with a fork-and-own contingency, not adopt and forget.
- Should I use clue/graph instead of a graph database or recursive queries in Laravel?
- No, not for querying large or first-class persisted relationship sets. Use recursive CTEs, join tables, or a graph database when relationships are the domain model and need database-level querying. clue/graph fits when the graph is a bounded, already-materialized computation inside your Laravel service layer.