Weave Code
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

Schema Org Laravel Package

spatie/schema-org

Fluent PHP builder for Schema.org: generate any type and property from the full core vocabulary and output valid JSON-LD (ld+json) script tags. Generated from the official Schema.org JSON-LD, with documented classes and methods.

View on GitHub
Deep Wiki
Context7

A fluent builder Schema.org types and ld+json generator

Frequently asked questions about Schema Org
How do I install spatie/schema-org in a Laravel project?
Run `composer require spatie/schema-org` in your project directory. The package has no Laravel-specific dependencies and works with PHP 8.1+. No additional configuration is needed unless you want to integrate it with Laravel’s service container or Blade templates.
Can I use this package to generate Schema.org markup for e-commerce products?
Yes, the package fully supports Schema.org’s `Product`, `Offer`, and `AggregateRating` types. Use the fluent builder to chain properties like `name()`, `price()`, `review()`, and nested types such as `brand()`. Example: `Schema::type('Product')->name('Laptop')->price(999)->review('5★')`.
Does spatie/schema-org support nested Schema.org types like LocalBusiness with ContactPoint?
Absolutely. The package allows composing nested graphs seamlessly. For example, create a `LocalBusiness` with a `ContactPoint` like this: `Schema::localBusiness()->contactPoint(Schema::contactPoint()->areaServed('Worldwide'))`. The output will include the nested JSON-LD structure.
How do I embed the generated JSON-LD into a Laravel Blade template?
Use a view composer to inject the Schema.org data. In your `AppServiceProvider`, add a composer for the view: `$view->with('schema', Schema::type('Article')->author('John Doe'))`. Then, in your Blade template, output it with `<script type="application/ld+json">{{ $schema->toScript() }}</script>`.
What Laravel versions does spatie/schema-org support?
The package is compatible with Laravel 9.x and 10.x, as it requires PHP 8.1+. It has no Laravel-specific dependencies, so it will work in any Laravel project meeting the PHP version requirement. Test thoroughly if using older Laravel versions with PHP 8.1+.
How do I validate the generated JSON-LD before deploying to production?
Use Google’s [Rich Results Test](https://search.google.com/test/rich-results) to validate your markup. For automated testing, integrate the package’s output into Laravel’s testing suite by comparing the generated JSON-LD against expected schemas. Example: `assertJson($response->content(), ['@type' => 'Product']);`.
Can I use this package in non-Laravel PHP applications like Symfony?
Yes, spatie/schema-org is a standalone PHP library with no Laravel dependencies. It works anywhere PHP 8.1+ runs, including Symfony, standalone scripts, or other frameworks. The fluent API remains consistent across environments.
How does the package handle updates to Schema.org’s vocabulary?
The package generates its code from Schema.org’s official JSON-LD standards file (currently v13.0). While updates may require package updates, the maintainers monitor Schema.org releases. Check the [release notes](https://github.com/spatie/schema-org/releases) for compatibility changes and test against new versions preemptively.
Is there a performance impact when generating complex nested Schema.org types?
The package is optimized for performance with minimal runtime overhead. However, extremely complex nested types (e.g., hundreds of items) could impact response times. Benchmark with your expected payload sizes and cache generated JSON-LD in Blade views or API responses if reused frequently.
What alternatives exist for generating Schema.org JSON-LD in Laravel?
Alternatives include manually writing JSON-LD or using libraries like `digitalbrain/schema.org` or `webmozart/schema-org`. However, spatie/schema-org stands out for its **complete coverage of Schema.org’s core vocabulary**, auto-generated from the official standards, and a fluent, IDE-friendly API. It’s ideal for projects requiring scalability and maintainability.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport