pietercolpaert/hardf
A PHP RDF library for parsing and serializing Turtle, TriG, N-Triples, and N-Quads. HARDF offers a lightweight API for reading and writing RDF triples and quads, useful for linked data and semantic web projects.
Architecture fit. hardf is a dependency-free, low-level RDF 1.2 codec — a parser/serializer, not a Laravel package. There is no service provider, no config file, no facade, no Eloquent or queue integration, and no opinion about your application structure. That is not a defect; it means the library belongs inside a domain service, behind an anti-corruption layer, rather than being wired into the framework. The natural home is something like app/Domain/Rdf/ or app/Services/LinkedData/, consumed by queued jobs and artisan commands (bulk ingest, export, validation), not by request-cycle controller code.
Integration feasibility. Straightforward mechanically: composer require pietercolpaert/hardf, PSR-4 autoload, MIT license, no native extensions or system binaries, so Docker/CI images are unaffected. The real constraints are (a) the PHP version floor and the versions the maintainer actually tests against, and (b) RDF 1.2 itself, which is still stabilizing (triple terms/reifiers, directional language-tagged strings). A library that tracks a moving specification will have a moving API; expect minor-version behavior changes in exactly the edge cases you care about.
Technical risk.
Key questions to resolve before committing.
easyrdf/easyrdf, sweetrdf) that covers 80% of our need with better support?Stack fit. Wrap it. Define an internal contract — e.g. RdfParser::parse(string $payload, string $format): iterable and RdfSerializer::serialize(iterable $quads, string $format): string — with a HardfRdfParser implementation bound in a service provider. Keep hardf value objects (quads, triples, terms) out of controllers, jobs' public signatures, and Eloquent models; convert immediately into your own DTOs, then into your persistence target (a triple store, a JSON projection, or relational tables). This single decision caps the blast radius if the package is abandoned or the RDF 1.2 API shifts.
Migration path. If you are currently on easyrdf/easyrdf, semsol/arc2, or hand-rolled JSON-LD handling, migrate format-by-format behind the new interface rather than in one cutover. Build a golden corpus of representative fixtures first, run old and new implementations side by side, and diff normalized output. Greenfield work needs no migration — gate the first consumer behind a feature flag and keep the old path warm for one release.
Compatibility. Framework-agnostic, so Laravel 10/11/12 is irrelevant; the binding constraints are PHP version and any transitive requirements (likely none). Safe under Octane and long-running workers provided you instantiate per job and do not cache parser state; verify there is no static/global accumulator before running under Octane.
Sequencing.
Maintenance. The library itself is small and dependency-free, which is genuinely cheap to keep running — no config drift, no framework upgrade coupling, no transitive CVE surface to chase. What you own is upgrade evaluation: because the code follows a moving spec, "patch version bump" is not a no-op category. Pin exact versions in composer.json, upgrade deliberately with the golden corpus as the gate, and never let it float.
Support. No commercial support, no vendor, no meaningful Stack Overflow corpus, and a small issue tracker where response times are best-effort. Internal expertise is the support model. Name an owner (one engineer, not a team) and budget a small recurring allocation for upstream tracking and spec changes.
Scaling. Parsing is CPU-bound and single-threaded per process; scale horizontally with queue workers rather than looking for concurrency inside the library. Streaming parse keeps memory flat on input, but verify the serializer side — document-building serializers can materialize the whole graph. Large graphs need a partitioning or pagination strategy that is orthogonal to hardf; do not expect it to solve that.
Failure modes to design for.
composer update in exactly the RDF 1.2 corners you rely on.Ramp-up. The library's API is small, so a strong PHP engineer is productive within a day or two. The real cost is RDF literacy: triples vs quads, named graphs, IRIs, blank-node scoping, Turtle vs TriG, and what "RDF 1.2" adds. That knowledge is not in the README and is the actual onboarding tax. Mitigate with an internal cookbook covering your three to five concrete use cases, plus the golden-corpus tests as living documentation.
Bottom line. The code risk is low; the dependency risk is moderate and the knowledge risk is the one that most often kills RDF integrations in PHP shops. Adopt behind an adapter, pin versions, start with one internal pipeline, and confirm format coverage and PHP-version support in the spike before any wider commitment.
How can I help you explore Laravel packages today?