superinteractive / super-structured-data
Structured data schema orchestration for Laravel with optional Statamic support.
Package info
github.com/superinteractive/super-structured-data
pkg:composer/superinteractive/super-structured-data
Requires
- php: ^8.4
- illuminate/console: ^12.0
- illuminate/contracts: ^12.0
- illuminate/support: ^12.0
- illuminate/view: ^12.0
- spatie/schema-org: ^3.23
Requires (Dev)
- laravel/pint: ^1.24
- mockery/mockery: ^1.6
- orchestra/testbench: ^10.0
- pestphp/pest: ^3.8
- phpunit/phpunit: ^11.5
Suggests
- statamic/cms: Optional: enables Statamic-specific schema context and factory support
This package is auto-updated.
Last update: 2026-02-24 15:10:57 UTC
README
superinteractive/super-structured-data provides a small schema runtime for JSON-LD in Laravel applications, with optional Statamic-aware context support.
Features
- 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.
Installation
composer require superinteractive/super-structured-data
Publish Configuration
php artisan vendor:publish --tag=structured-data-config
Publish Homepage Schema Stubs
php artisan vendor:publish --tag=structured-data-homepage-schemas
This publishes:
app/Schemas/HomepageOrganizationSchema.phpapp/Schemas/HomepageWebsiteSchema.php
Create a New Schema
Artisan:
php artisan make:schema Product
Statamic please (when Statamic is installed):
php please make:schema Product
The command appends Schema automatically, so Product generates ProductSchema.
Configuration
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', ], ];
Override Context Classes
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.
Writing Schemas
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(), ]; } }
Rendering
Use the component in Blade:
<x-structured-data :entry="$entry" />
entry is optional. In Laravel-only projects, you can omit it.
Testing
Run package tests:
composer test
Format package code:
vendor/bin/pint
Support Matrix
- PHP: 8.4+
- Laravel: 12+
- Statamic: optional