Framework-agnostic Schema.org JSON-LD engine for PHP 7.4+.
The independent core behind the SchemaWeave WordPress plugin.
SchemaWeave PHP is a small, dependency-light structured-data engine that can be embedded in custom PHP applications, CMS projects, PDO-based systems and framework adapters.
It is intentionally separate from WordPress. The WordPress integration lives in SchemaWeave, while this repository remains the source of truth for the core engine.
- Generate structured data from real application data.
- Do not fabricate prices, offers, SKU/MPN identifiers, ratings or reviews.
- Keep the core independent from WordPress and other frameworks.
- Allow data providers, URL resolvers and schema extensions to be replaced.
- Build one coherent
@graphwith stable entity relationships. - Omit incomplete entities instead of emitting broken structured data.
OrganizationWebSiteLocalBusinessWebPageAboutPageContactPageProfilePageSearchResultsPageCollectionPageProductBlogPostingBreadcrumbListItemListFAQPage- custom entities through the extension API
- PHP 7.4 or newer
The package metadata is ready for:
composer require erenkoyuncu/schemaweavePackagist publication can follow the public GitHub
v1.0.0release. Until then, use the repository or a release archive directly.
<?php
require __DIR__ . '/vendor/autoload.php';
use SchemaWeave\Config;
use SchemaWeave\SchemaEngine;
$engine = new SchemaEngine(new Config([
'base_url' => 'https://example.com',
'site_name' => 'Acme Demo',
'organization' => [
'name' => 'Acme Demo',
],
]));
$graph = $engine->generate([
'type' => 'page',
'name' => 'About Us',
'url' => 'https://example.com/about',
]);
echo $graph->toScriptTag();SchemaWeave PHP is built around replaceable contracts rather than a specific CMS.
Application / CMS
│
├── DataProviderInterface
├── UrlResolverInterface
└── Config
│
▼
SchemaEngine
│
├── Organization
├── WebSite
├── WebPage
├── Product
├── BlogPosting
├── BreadcrumbList
├── ItemList
└── FAQPage
│
▼
SchemaGraph
Ready-to-use implementations include array and callback data providers plus the default URL resolver.
See docs/ARCHITECTURE.md for more detail.
The core exposes:
DataProviderInterfaceUrlResolverInterfaceSchemaExtensionInterface
Examples are available for:
- plain PHP,
- PDO-backed applications,
- custom data providers,
- custom schema extensions.
See the examples/ directory and PHP integration guide.
Missing commercial or reputation data is omitted instead of invented.
For example, a Product without a real price should not suddenly gain a made-up Offer, and content without real review data should not gain an AggregateRating.
JSON-LD script output is encoded to prevent HTML/script breakout sequences while preserving valid JSON-LD. Date helpers normalize structured-data timestamps without silently applying an unrelated server timezone.
The WordPress plugin bundles a release copy of this engine so WordPress.org users do not need Composer.
| Repository | Purpose |
|---|---|
| SchemaWeave-PHP | Core engine, contracts, graph generation and tests |
| SchemaWeave | WordPress/WooCommerce adapter, admin UI, FAQ display, diagnostics and WP-CLI |
Run the core tests with:
php tests/run.phpThe suite covers graph generation, extensions, data-integrity behavior, dates, validation and output escaping.
See SECURITY.md.
Issues and pull requests are welcome. See CONTRIBUTING.md.
SchemaWeave PHP is released under the MIT License. See LICENSE.
