clue/graph
Clue\Graph is a lightweight graph/network library for PHP that models nodes and edges so you can traverse, query, and analyze connected data. It works with graphs, trees, and other structures via a simple API.
Architecture fit. clue/graph is a framework-agnostic, in-memory graph/network library: it provides vertex/edge containers (directed and undirected), weighted edges, and classic traversal/shortest-path algorithms (Dijkstra, Moore-Bellman-Ford, topological sorting). It has no Laravel service provider, no facade, no Eloquent coupling, and no persistence layer. That makes it a good fit as a computational kernel inside the domain layer — a pure-PHP engine that a Laravel service, action, or queued job calls with an already-materialized subgraph. It is a poor fit as a relationship query layer: it will not replace recursive CTEs, join tables, or a graph database for querying large relationship sets. The architectural decision to make early is whether the graph is a bounded, transient computation (good fit) or a first-class persisted domain model (poor fit — you would be building the persistence layer yourself).
Integration feasibility. Composer-installable with a very small dependency footprint, which keeps supply-chain surface low. The real integration work is not installing the package but writing the adapter/mapper layer: hydrating vertices from Eloquent models (or query results), attaching weights from domain attributes, running the algorithm, and mapping results back to IDs. That is typically a few days of work for one bounded use case, and it is where most of the long-term maintenance cost will live. Practical early candidates: dependency/DAG validation (topological sort), pricing or logistics shortest-path over a bounded network, workflow/state-machine reachability, permission-inheritance resolution over a small hierarchy, or recommendation-adjacency traversal on a pre-filtered node set.
Technical risk.
php to older ranges, it can block or complicate framework upgrades even though the code would run fine.SplObjectStorage. Memory and runtime scale poorly past tens of thousands of nodes/edges, and building the graph each request is pure overhead. Not viable for per-request computation over a large dataset.Key questions.
composer.json accept our PHP and Laravel version constraints without --ignore-platform-reqs?Stack fit. Zero-friction install path: composer require clue/graph, no provider registration, no config publishing, no migrations. Recommended shape is an anti-corruption layer — define a GraphSolver/Pathfinder interface in the application layer, bind a ClueGraphAdapter implementation in a service provider, and let domain services depend only on the interface. This keeps the package swappable (to a fork, to a native implementation, or to a graph service) and confines the third-party API to one or two classes. Do not let Clue\Graph\... types leak into controllers, Eloquent models, or API resources.
Migration path. There is no data migration — the package stores nothing. The migration is conceptual: replace whatever ad-hoc traversal currently exists (nested loops, recursive queries, hand-rolled DFS) with explicit graph modeling. Start with a single bounded feature behind a feature flag, run it in shadow mode against the existing implementation for a release cycle, compare outputs, then cut over. If the existing approach is database-side recursive SQL, keep it as the fallback path rather than deleting it in the same release.
Compatibility. Confirm and pin: PHP constraint, presence of any transitive dependencies, and behavior under our exact PHP minor version. Run the package's own test suite against our runtime as an acceptance gate. Pin to the exact current version in composer.lock and add it to the dependency-review list so an unexpected release (or its absence at upgrade time) is a conscious decision. If the constraint graph conflicts with a planned Laravel upgrade, resolve it by vendoring/forks — an internal fork under our namespace, with the upstream diff kept small, is the cheapest durable answer for a library this size.
Sequencing.
Maintenance. Runtime maintenance is near zero — it is inert, deterministic code with no I/O, no network, and no state. The maintenance burden is entirely in (a) the adapter layer we own and (b) the periodic decision about what to do when the package blocks a platform upgrade. Budget a small, recurring line item for "dependency health review" rather than continuous work. Assign a named owner for the fork contingency; unowned forks rot faster than the original.
Support. Community-only. No vendor, no SLA, no guaranteed response on issues, and a repository we cannot currently verify. For an internal-only computational library that is acceptable; for anything customer-facing and revenue-critical on the hot path, the internal-ownership model must be explicit before launch. MIT licensing is clean for commercial and closed-source use, with the usual attribution obligation.
Scaling. Scale is bounded by process memory, not by the library's asymptotics — the algorithms are standard O(V+E) and O(V log V)-class. Practical guidance: keep graphs under a size you have actually measured; execute computations in queued workers rather than the HTTP request cycle; cache results keyed by graph-version so repeated identical queries do not rehydrate; pre-filter node sets in SQL before handing them to the solver. The scaling failure mode is not "slow algorithm," it is "we hydrated 200k Eloquent models to answer one question." Persist any graph that is queried repeatedly rather than rebuilding it per request.
Failure modes.
composer require.Ramp-up. Low. The API is small and idiomatic; a mid-level PHP developer is productive in a day. The non-obvious cost is domain modeling literacy — deciding what a vertex and edge mean in our business terms, what the weights represent, and what "shortest" should optimize. That conversation takes longer than the code and should involve the product owner, not just the implementer. Net assessment: worth adopting for one or two well-bounded algorithmic use cases behind an owned abstraction, with an explicit fork contingency; not worth adopting as the foundation of a relationship-query strategy.
How can I help you explore Laravel packages today?