Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Json Ld Laravel Package

torann/json-ld

torann/json-ld is a Laravel package for generating JSON-LD structured data. It provides a fluent builder for schema.org markup, supports multiple schema types, and makes adding SEO-friendly rich results to your application simple.

View on GitHub
Deep Wiki
Context7

torann/json-ld is a Laravel package for building and rendering JSON-LD structured data through a fluent PHP API. It makes adding Schema.org markup straightforward, helping search engines interpret page content and improve eligibility for rich results.

  • Fluent builders for Schema.org types and properties
  • Seamless Laravel integration via facade and service provider
  • Support for nested entities and custom schemas
  • Simple <script type="application/ld+json"> output
  • Configurable rendering for multiple structured-data blocks
Frequently asked questions about Json Ld
How do I install torann/json-ld in a Laravel application?
Install it with composer require torann/json-ld; Laravel package auto-discovery registers the service provider and facade, so no manual edits to config/app.php are typically needed on modern Laravel versions. Publish the package config if you need to adjust rendering behavior for multiple structured-data blocks. Because the latest tagged release is 0.0.19 from March 2020, run the install on a branch first and confirm Composer resolves illuminate/support against your actual PHP and Laravel versions.
Does torann/json-ld support Laravel 10 or Laravel 11?
Not guaranteed: the last release is 0.0.19 from March 2020, which aligns with Laravel 6/7-era illuminate/support constraints, so a clean Composer resolve on Laravel 10 or 11 cannot be assumed. Test composer require torann/json-ld on a throwaway branch against your exact PHP and Laravel versions before planning around it. Avoid --ignore-platform-reqs as a workaround, since that converts a clean incompatibility into an unowned upgrade liability. If the resolve fails, the presenter wrapper you would write is essentially identical against spatie/schema-org, so switching costs about a day.
How do I output JSON-LD in a Blade template with torann/json-ld?
Build the schema in a presenter or view composer and echo the rendered script tag inside the head of your layout. Use unescaped Blade output, {!! $jsonLd !!}, rather than {{ }}, because entity-encoding the payload invalidates the structured data and search engines will drop it. Keep the call out of controllers and models by putting it behind a small SchemaPresenter interface so the package remains an implementation detail.
How do I stop a </script> string in my data from breaking the JSON-LD block?
Encode the payload with JSON_HEX_TAG, or substitute forward slashes so a literal closing script tag appears as <\/ in the JSON, preventing a title or description from terminating the block early. Combine that with unescaped Blade output; using {{ }} instead re-encodes quotes and produces invalid JSON. This is a well-understood escaping concern you must handle yourself, not something the package guarantees.
Can torann/json-ld build nested entities and multiple schema types on one page?
Yes. The package supports nested entities and custom schemas, so you can attach an Organization to a WebSite or an Offer and AggregateRating to a Product through the fluent builder. Rendering is configurable for multiple structured-data blocks, though the common convention is a single @graph per page with stable @ids rather than several disconnected script tags.
How do I add a custom Schema.org type that isn't built in?
Use the package's support for custom schemas to define the type and its properties through the fluent builder. Verify the emitted JSON against Schema.org and Google's required-field list for that type, since the package only outputs arrays and performs no validation. If the type needs to be governed consistently across many templates, treat that as a content-modelling decision rather than a package feature.
How should I test JSON-LD output in a Laravel feature test?
Assert on the rendered HTML: request the page, extract the contents of the application/ld+json script tag, json_decode it, and check the fields Google requires for that schema type. Run the same page through Google's Rich Results Test as a manual acceptance check. Proving it on one template first gives you a cheap, objective go/no-go before rolling it out further.
Is torann/json-ld maintained and safe to use in production?
It is a single-maintainer package with no release since 0.0.19 in March 2020 and no security policy, so treat it as a code snapshot you are adopting rather than a vendor relationship. That is acceptable for a small presentation-layer helper, especially under BSD-2-Clause, which makes vendoring and forking legally frictionless. The real production risk is content governance rather than code: fabricated aggregateRating values, invented availability, and stale prices are manual-action risks from Google that no package can prevent.
What are the alternatives to torann/json-ld?
spatie/schema-org is the most common actively maintained alternative and exposes a comparable fluent builder API, which is why switching away from torann/json-ld is roughly a day of work. You can also hand-build arrays and json_encode them if you only need one or two schema types. Choose based on whether upstream maintenance matters more to you than the Laravel facade ergonomics.
Where should I call torann/json-ld in my application architecture?
At the edge of the request lifecycle: a presenter builds the schema array and the layout head emits the script tag. Put it behind an internal SchemaPresenter interface with one presenter per schema type so the package never appears in a controller, a model, or an architecture diagram. If a proposal requires it to handle validation, schema governance, or automated generation across heterogeneous templates, that is scope creep and should be declined.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource