Getting Started
This library helps to extract schema.org structured data in JSON-LD format from HTML documents. It tries to find JavaScript tags in HTML containing JSON-LD objects, getting the data and populating instances of the equivalent classes from spatie's schema-org package. Shout-out to the awesome guys at spatie!
Requirements
Requires PHP version 8.0 or above.
Install
Install the latest version with:
composer require crwlr/schema-org
Usage
Using it is super simple:
use Crwlr\SchemaOrg\SchemaOrg;
$html = file_get_contents('https://some.example.com/containing/schema-org-data');
$schemaOrgObjects = SchemaOrg::fromHtml($html);
The SchemaOrg::fromHtml()
method returns an array with the schema.org objects (instances from the spatie schema-org package).