superinteractive/super-structured-data provides a small schema runtime for JSON-LD in Laravel applications, with optional Statamic-aware context support.
- Auto-discovery of schemas from
app/Schemas(or a configurable schema path). - Blade component output via
<x-structured-data>. - Publishable config and homepage schema stubs.
make:schemagenerator command.- Configurable context class and context factory.
composer require superinteractive/super-structured-dataphp artisan vendor:publish --tag=structured-data-configphp artisan vendor:publish --tag=structured-data-homepage-schemasThis publishes:
app/Schemas/HomepageOrganizationSchema.phpapp/Schemas/HomepageWebsiteSchema.php
Artisan:
php artisan make:schema ProductStatamic please (when Statamic is installed):
php please make:schema ProductThe command appends Schema automatically, so Product generates ProductSchema.
Default package config:
return [
'enabled' => true,
'schema_path' => 'Schemas',
'classes' => [
'class' => class_exists('Statamic\\Statamic')
? 'Superinteractive\\StructuredData\\Contexts\\StatamicSchemaContext'
: 'Superinteractive\\StructuredData\\Contexts\\LaravelSchemaContext',
'factory' => class_exists('Statamic\\Statamic')
? 'Superinteractive\\StructuredData\\Factories\\StatamicSchemaContextFactory'
: 'Superinteractive\\StructuredData\\Factories\\LaravelSchemaContextFactory',
],
];Laravel-only example:
return [
'classes' => [
'class' => Superinteractive\StructuredData\Contexts\LaravelSchemaContext::class,
'factory' => Superinteractive\StructuredData\Factories\LaravelSchemaContextFactory::class,
],
];Custom app-specific context example:
return [
'classes' => [
'class' => App\StructuredData\CustomSchemaContext::class,
'factory' => App\StructuredData\CustomSchemaContextFactory::class,
],
];Your custom factory must implement Superinteractive\StructuredData\Contracts\SchemaContextFactoryContract and return an instance of the configured classes.class.
Generated schemas extend Superinteractive\StructuredData\Schemas\BaseSchema.
Reference material:
- Spatie schema-org GitHub: spatie/schema-org
- Spatie schema-org package docs: packagist.org/packages/spatie/schema-org
- Schema.org reference types: schema.org/docs/full.html
Example:
<?php
declare(strict_types=1);
namespace App\Schemas;
use Spatie\SchemaOrg\Schema;
use Superinteractive\StructuredData\Schemas\BaseSchema;
class ProductSchema extends BaseSchema
{
public function applies(): bool
{
return $this->context->routeName() === 'products.show';
}
public function scripts(): array
{
if (! $this->applies()) {
return [];
}
return [
Schema::product()->name('Example product')->toScript(),
];
}
}Use the component in Blade:
<x-structured-data :entry="$entry" />entry is optional. In Laravel-only projects, you can omit it.
Run package tests:
composer testFormat package code:
vendor/bin/pint- PHP: 8.4+
- Laravel: 12+
- Statamic: optional