1. Go to this page and download the library: Download evabee/schema-org-json-ld library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
evabee / schema-org-json-ld example snippets
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Article;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Person;
$article = new Article(
headline: 'How to Use Schema.org JSON-LD in PHP',
author: new Person(name: 'Jane Smith'),
datePublished: '2026-01-15',
);
$json = JsonLdGenerator::SchemaToJson(schema: $article);
// Embed in your HTML <head>:
// <script type="application/ld+json"><?= $json
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Article;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Organization;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Person;
$article = new Article(
headline: 'How to Use Schema.org JSON-LD in PHP',
author: new Person(name: 'Jane Smith', url: 'https://example.com/jane'),
datePublished: '2026-01-15',
dateModified: '2026-02-01',
image: ['https://example.com/photos/article.jpg'],
publisher: new Organization(
name: 'Example Media',
url: 'https://example.com',
logo: 'https://example.com/logo.png',
),
);
$json = JsonLdGenerator::SchemaToJson(schema: $article);
use EvaLok\SchemaOrgJsonLd\v1\Schema\NewsArticle;
use EvaLok\SchemaOrgJsonLd\v1\Schema\BlogPosting;
$newsArticle = new NewsArticle(headline: 'Breaking: PHP 8.4 Released', datePublished: '2026-01-20');
$blogPost = new BlogPosting(headline: 'My Journey Learning PHP', datePublished: '2026-02-10');
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\BreadcrumbList;
use EvaLok\SchemaOrgJsonLd\v1\Schema\ListItem;
$breadcrumb = new BreadcrumbList(
itemListElement: [
new ListItem(position: 1, name: 'Home', item: 'https://example.com'),
new ListItem(position: 2, name: 'Books', item: 'https://example.com/books'),
new ListItem(position: 3, name: 'Science & Nature', item: 'https://example.com/books/science'),
],
);
$json = JsonLdGenerator::SchemaToJson(schema: $breadcrumb);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\ItemList;
use EvaLok\SchemaOrgJsonLd\v1\Schema\ListItem;
$carousel = new ItemList(
itemListElement: [
new ListItem(position: 1, url: 'https://example.com/articles/1'),
new ListItem(position: 2, url: 'https://example.com/articles/2'),
new ListItem(position: 3, url: 'https://example.com/articles/3'),
],
itemListOrder: 'ItemListOrderAscending',
numberOfItems: 3,
);
$json = JsonLdGenerator::SchemaToJson(schema: $carousel);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\AggregateRating;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Course;
use EvaLok\SchemaOrgJsonLd\v1\Schema\CourseInstance;
use EvaLok\SchemaOrgJsonLd\v1\Enum\ItemAvailability;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Offer;
use EvaLok\SchemaOrgJsonLd\v1\Enum\OfferItemCondition;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Organization;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Person;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Schedule;
$course = new Course(
name: 'Advanced PHP Development',
description: 'Master PHP 8.x features, design patterns, and best practices.',
provider: new Organization(name: 'PHP Academy', url: 'https://phpacademy.example.com'),
hasCourseInstance: [
new CourseInstance(
courseMode: 'online',
instructor: new Person(name: 'Prof. Alice Dev'),
courseSchedule: new Schedule(repeatFrequency: 'P1W', repeatCount: 12),
),
],
offers: [
new Offer(
url: 'https://phpacademy.example.com/advanced-php',
priceCurrency: 'USD',
price: 199.0,
itemCondition: OfferItemCondition::NewCondition,
availability: ItemAvailability::InStock,
),
],
courseCode: 'CS101',
inLanguage: 'en',
totalHistoricalEnrollment: 15000,
aggregateRating: new AggregateRating(ratingValue: 4.8, reviewCount: 342, bestRating: 5),
image: 'https://example.com/images/web-dev-course.jpg',
);
$json = JsonLdGenerator::SchemaToJson(schema: $course);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\DataDownload;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Dataset;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Organization;
$dataset = new Dataset(
name: 'PHP Developer Survey 2025',
description: 'Annual survey of PHP developer demographics and tool usage.',
url: 'https://example.com/datasets/php-survey-2025',
sameAs: 'https://doi.org/10.5281/zenodo.1234567',
creator: new Organization(name: 'PHP Foundation'),
license: 'https://creativecommons.org/licenses/by/4.0/',
keywords: ['PHP', 'developer survey', 'programming'],
isAccessibleForFree: true,
temporalCoverage: '2020-01-01/2025-12-31',
distribution: [
new DataDownload(
contentUrl: 'https://example.com/datasets/php-survey-2025.csv',
encodingFormat: 'text/csv',
),
],
version: '2.1',
citation: 'Doe, J. (2026). Example Climate Dataset. Zenodo.',
);
$json = JsonLdGenerator::SchemaToJson(schema: $dataset);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\DiscussionForumPosting;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Person;
$post = new DiscussionForumPosting(
author: new Person(name: 'ForumUser42', url: 'https://forum.example.com/users/42'),
datePublished: '2026-01-10T14:30:00+00:00',
text: 'What is the best way to handle database migrations in PHP?',
headline: 'Best approach for DB migrations?',
url: 'https://forum.example.com/threads/db-migrations',
);
$json = JsonLdGenerator::SchemaToJson(schema: $post);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\AlignmentObject;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Answer;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Question;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Quiz;
$quiz = new Quiz(
hasPart: [
new Question(
name: 'What does PHP stand for?',
eduQuestionType: 'MultipleChoice',
acceptedAnswer: new Answer(text: 'PHP: Hypertext Preprocessor'),
suggestedAnswer: [
new Answer(text: 'Personal Home Page'),
new Answer(text: 'Hypertext Preprocessor'),
],
),
],
name: 'PHP Basics Quiz',
about: 'PHP programming language fundamentals',
educationalAlignment: new AlignmentObject(
alignmentType: 'educationalLevel',
targetName: 'Beginner',
),
);
$json = JsonLdGenerator::SchemaToJson(schema: $quiz);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\EmployerAggregateRating;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Organization;
$employerRating = new EmployerAggregateRating(
itemReviewed: new Organization(name: 'TechCorp Inc.', url: 'https://techcorp.example.com'),
ratingValue: 4.2,
ratingCount: 350,
bestRating: 5,
worstRating: 1,
);
$json = JsonLdGenerator::SchemaToJson(schema: $employerRating);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Event;
use EvaLok\SchemaOrgJsonLd\v1\Enum\EventAttendanceModeEnumeration;
use EvaLok\SchemaOrgJsonLd\v1\Enum\EventStatusType;
use EvaLok\SchemaOrgJsonLd\v1\Enum\ItemAvailability;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Offer;
use EvaLok\SchemaOrgJsonLd\v1\Enum\OfferItemCondition;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Organization;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Place;
use EvaLok\SchemaOrgJsonLd\v1\Schema\PostalAddress;
use EvaLok\SchemaOrgJsonLd\v1\Schema\VirtualLocation;
$event = new Event(
name: 'PHP Conference 2026',
startDate: '2026-06-15T09:00:00+00:00',
location: [
new Place(
name: 'Convention Center',
address: new PostalAddress(
streetAddress: '123 Main St',
addressLocality: 'San Francisco',
addressRegion: 'CA',
postalCode: '94102',
addressCountry: 'US',
),
),
new VirtualLocation(url: 'https://stream.example.com/phpconf2026', name: 'Livestream'),
],
description: 'The premier PHP conference on the west coast.',
endDate: '2026-06-17T17:00:00+00:00',
eventAttendanceMode: EventAttendanceModeEnumeration::MixedEventAttendanceMode,
eventStatus: EventStatusType::EventScheduled,
image: ['https://example.com/phpconf2026.jpg'],
organizer: new Organization(name: 'PHP Foundation', url: 'https://php.foundation'),
offers: [
new Offer(
url: 'https://phpconf2026.example.com/tickets',
priceCurrency: 'USD',
price: 299.0,
itemCondition: OfferItemCondition::NewCondition,
availability: ItemAvailability::InStock,
),
],
);
$json = JsonLdGenerator::SchemaToJson(schema: $event);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Answer;
use EvaLok\SchemaOrgJsonLd\v1\Schema\FAQPage;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Question;
$faq = new FAQPage(
mainEntity: [
new Question(
name: 'What is schema.org JSON-LD?',
acceptedAnswer: new Answer(
text: 'Schema.org JSON-LD is a method of encoding structured data in a JSON format to help search engines understand your content.',
),
),
new Question(
name: 'Does Google support JSON-LD?',
acceptedAnswer: new Answer(
text: 'Yes, Google recommends JSON-LD as the preferred format for structured data markup.',
),
),
],
);
$json = JsonLdGenerator::SchemaToJson(schema: $faq);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\MathSolver;
use EvaLok\SchemaOrgJsonLd\v1\Schema\SolveMathAction;
$mathSolver = new MathSolver(
url: 'https://example.com/math-solver',
usageInfo: 'https://example.com/math-solver/usage',
potentialAction: new SolveMathAction(
target: 'https://example.com/math-solver?expression={math_expression}',
mathExpressionInput: 'x^2 + 4x + 4 = 0',
),
name: 'Equation Solver',
inLanguage: 'en',
learningResourceType: 'Math solver',
assesses: ['Algebra', 'Equations'],
);
$json = JsonLdGenerator::SchemaToJson(schema: $mathSolver);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\AggregateRating;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Movie;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Person;
$movie = new Movie(
name: 'The PHP Chronicles',
image: 'https://example.com/movies/php-chronicles-poster.jpg',
dateCreated: '2026-03-01',
director: new Person(name: 'Alice Director'),
aggregateRating: new AggregateRating(ratingValue: 7.5, ratingCount: 4200, bestRating: 10),
description: 'An epic journey through the history of PHP.',
actor: [new Person(name: 'Bob Actor'), new Person(name: 'Carol Actress')],
);
$json = JsonLdGenerator::SchemaToJson(schema: $movie);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\ContactPoint;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Organization;
use EvaLok\SchemaOrgJsonLd\v1\Schema\PostalAddress;
use EvaLok\SchemaOrgJsonLd\v1\Schema\QuantitativeValue;
$org = new Organization(
name: 'PHP Foundation',
url: 'https://php.foundation',
logo: 'https://php.foundation/logo.png',
description: 'Supporting the PHP ecosystem.',
email: '[email protected]',
telephone: '+1-800-PHP-HELP',
address: new PostalAddress(
streetAddress: '1 Open Source Way',
addressLocality: 'San Francisco',
addressRegion: 'CA',
postalCode: '94105',
addressCountry: 'US',
),
contactPoint: new ContactPoint(
telephone: '+1-800-PHP-HELP',
contactType: 'customer support',
availableLanguage: 'English',
),
sameAs: ['https://github.com/php', 'https://twitter.com/php_net'],
foundingDate: '2021-11-22',
alternateName: 'The PHP Foundation',
legalName: 'PHP Foundation Inc.',
numberOfEmployees: new QuantitativeValue(value: 50),
// hasMerchantReturnPolicy: new MerchantReturnPolicy(...),
// hasMemberProgram: new MemberProgram(...),
// hasShippingService: new ShippingService(...),
);
$json = JsonLdGenerator::SchemaToJson(schema: $org);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Brand;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Certification;
use EvaLok\SchemaOrgJsonLd\v1\Schema\DefinedRegion;
use EvaLok\SchemaOrgJsonLd\v1\Enum\ItemAvailability;
use EvaLok\SchemaOrgJsonLd\v1\Schema\MonetaryAmount;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Offer;
use EvaLok\SchemaOrgJsonLd\v1\Enum\OfferItemCondition;
use EvaLok\SchemaOrgJsonLd\v1\Schema\OfferShippingDetails;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Organization;
use EvaLok\SchemaOrgJsonLd\v1\Schema\PeopleAudience;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Product;
use EvaLok\SchemaOrgJsonLd\v1\Schema\ProductGroup;
use EvaLok\SchemaOrgJsonLd\v1\Schema\QuantitativeValue;
use EvaLok\SchemaOrgJsonLd\v1\Schema\ShippingDeliveryTime;
use EvaLok\SchemaOrgJsonLd\v1\Schema\SizeSpecification;
use EvaLok\SchemaOrgJsonLd\v1\Schema\UnitPriceSpecification;
$product = new Product(
name: 'Executive Anvil',
image: [
'https://example.com/photos/1x1/photo.jpg',
'https://example.com/photos/4x3/photo.jpg',
'https://example.com/photos/16x9/photo.jpg',
],
description: "Sleeker than ACME's Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.",
sku: '0446310786',
brand: new Brand(name: 'ACME (tm)'),
mpn: 'ACME0444246625',
weight: new QuantitativeValue(value: 55.67, unitCode: 'LBR'),
size: new SizeSpecification(name: 'M', sizeGroup: 'Mens', sizeSystem: 'US'),
isVariantOf: new ProductGroup(
name: 'Executive Anvil',
productGroupID: 'anvil-executive-family',
variesBy: ['https://schema.org/size'],
),
audience: new PeopleAudience(suggestedGender: 'Male', suggestedMinAge: 18),
hasCertification: new Certification(
name: 'Business Traveler Safety Standard',
issuedBy: new Organization(name: 'ACME Compliance Board'),
),
offers: [
new Offer(
url: 'https://example.com/anvil',
priceCurrency: 'USD',
price: 119.99,
itemCondition: OfferItemCondition::NewCondition,
availability: ItemAvailability::InStock,
priceSpecification: new UnitPriceSpecification(
price: 119.99,
priceCurrency: 'USD',
priceType: 'https://schema.org/StrikethroughPrice',
),
shippingDetails: [
new OfferShippingDetails(
shippingDestination: new DefinedRegion(addressCountry: 'US', addressRegion: ['CA', 'NV', 'AZ']),
shippingRate: new MonetaryAmount(value: 3.49, currency: 'USD'),
deliveryTime: new ShippingDeliveryTime(
handlingTime: new QuantitativeValue(unitCode: 'DAY', minValue: 0, maxValue: 1),
transitTime: new QuantitativeValue(unitCode: 'DAY', minValue: 1, maxValue: 5),
),
),
new OfferShippingDetails(
shippingDestination: new DefinedRegion(addressCountry: 'US', addressRegion: ['AK']),
doesNotShip: true,
),
],
),
],
);
$json = JsonLdGenerator::SchemaToJson(schema: $product);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Person;
use EvaLok\SchemaOrgJsonLd\v1\Schema\ProfilePage;
$profile = new ProfilePage(
mainEntity: new Person(
name: 'Alice Dev',
url: 'https://example.com/alice',
image: 'https://example.com/alice/photo.jpg',
jobTitle: 'Senior PHP Developer',
description: 'Open source contributor and PHP enthusiast.',
sameAs: ['https://github.com/alicedev', 'https://linkedin.com/in/alicedev'],
),
dateCreated: '2020-01-01',
dateModified: '2026-01-15',
);
$json = JsonLdGenerator::SchemaToJson(schema: $profile);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Answer;
use EvaLok\SchemaOrgJsonLd\v1\Schema\QAPage;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Question;
$qa = new QAPage(
mainEntity: new Question(
name: 'How do I install Composer?',
text: 'I am new to PHP and want to know how to install Composer on Ubuntu.',
answerCount: 2,
acceptedAnswer: new Answer(
text: 'Run: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer',
upvoteCount: 142,
),
suggestedAnswer: [
new Answer(
text: 'You can also download the installer from https://getcomposer.org/download/ and run it manually.',
upvoteCount: 38,
),
],
),
);
$json = JsonLdGenerator::SchemaToJson(schema: $qa);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\AggregateRating;
use EvaLok\SchemaOrgJsonLd\v1\Schema\HowToSection;
use EvaLok\SchemaOrgJsonLd\v1\Schema\HowToStep;
use EvaLok\SchemaOrgJsonLd\v1\Schema\NutritionInformation;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Person;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Recipe;
$recipe = new Recipe(
name: "Grandma's Apple Pie",
image: [
'https://example.com/photos/applepie-1x1.jpg',
'https://example.com/photos/applepie-4x3.jpg',
],
author: new Person(name: 'Grandma Rose'),
datePublished: '2026-01-05',
description: 'The best apple pie recipe, passed down through generations.',
prepTime: 'PT30M',
cookTime: 'PT1H',
totalTime: 'PT1H30M',
recipeYield: '8 servings',
recipeCategory: 'Dessert',
recipeCuisine: 'American',
recipeIngredient: [
'6 large apples, peeled and sliced',
'3/4 cup sugar',
'1 teaspoon cinnamon',
'2 cups all-purpose flour',
],
recipeInstructions: [
new HowToSection(
name: 'Prepare pie',
itemListElement: [
new HowToStep(name: 'Prepare filling', text: 'Mix sliced apples with sugar and cinnamon in a large bowl.'),
new HowToStep(name: 'Make crust', text: 'Combine flour, butter, and water to form a dough. Roll out for crust.'),
new HowToStep(name: 'Bake', text: 'Pour filling into crust-lined pie dish, cover with top crust, bake at 375°F for 1 hour.'),
],
),
],
nutrition: new NutritionInformation(calories: '320 calories', fatContent: '12 g', carbohydrateContent: '52 g'),
aggregateRating: new AggregateRating(ratingValue: 4.9, ratingCount: 1200, bestRating: 5),
);
$json = JsonLdGenerator::SchemaToJson(schema: $recipe);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\AggregateRating;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Rating;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Review;
// Standalone review
$review = new Review(
author: 'Jane Reviewer',
reviewRating: new Rating(ratingValue: 4, bestRating: 5),
reviewBody: 'Excellent product! Works exactly as described and arrived quickly.',
datePublished: '2026-01-20',
name: 'Great product',
);
$json = JsonLdGenerator::SchemaToJson(schema: $review);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\AggregateRating;
use EvaLok\SchemaOrgJsonLd\v1\Enum\ItemAvailability;
use EvaLok\SchemaOrgJsonLd\v1\Schema\MobileApplication;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Offer;
use EvaLok\SchemaOrgJsonLd\v1\Enum\OfferItemCondition;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Person;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Rating;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Review;
use EvaLok\SchemaOrgJsonLd\v1\Schema\SoftwareApplication;
$app = new SoftwareApplication(
name: 'CodeHelper Pro',
offers: new Offer(
url: 'https://codehelper.example.com/buy',
priceCurrency: 'USD',
price: 9.99,
itemCondition: OfferItemCondition::NewCondition,
availability: ItemAvailability::InStock,
),
aggregateRating: new AggregateRating(ratingValue: 4.6, ratingCount: 8900, bestRating: 5),
applicationCategory: 'DeveloperApplication',
operatingSystem: 'Windows, macOS, Linux',
review: new Review(
author: new Person(name: 'Mike R.'),
reviewRating: new Rating(ratingValue: 5, bestRating: 5),
reviewBody: 'Excellent photo editor!',
),
description: 'A powerful photo editing application for professionals.',
screenshot: 'https://example.com/screenshots/photoeditor-main.png',
);
$json = JsonLdGenerator::SchemaToJson(schema: $app);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Article;
use EvaLok\SchemaOrgJsonLd\v1\Schema\SpeakableSpecification;
$article = new Article(
headline: 'Latest News: PHP Reaches New Heights',
datePublished: '2026-01-25',
speakable: new SpeakableSpecification(
cssSelector: ['.headline', '.summary'],
),
);
$json = JsonLdGenerator::SchemaToJson(schema: $article);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Article;
use EvaLok\SchemaOrgJsonLd\v1\Schema\WebPageElement;
$article = new Article(
headline: 'Premium: Advanced PHP Patterns Deep Dive',
datePublished: '2026-02-01',
isAccessibleForFree: false,
hasPart: new WebPageElement(
isAccessibleForFree: false,
cssSelector: '.premium-content',
),
);
$json = JsonLdGenerator::SchemaToJson(schema: $article);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Accommodation;
use EvaLok\SchemaOrgJsonLd\v1\Schema\AggregateRating;
use EvaLok\SchemaOrgJsonLd\v1\Schema\BedDetails;
use EvaLok\SchemaOrgJsonLd\v1\Schema\PostalAddress;
use EvaLok\SchemaOrgJsonLd\v1\Schema\QuantitativeValue;
use EvaLok\SchemaOrgJsonLd\v1\Schema\VacationRental;
$rental = new VacationRental(
name: 'Beachside Cottage',
identifier: 'cottage-42',
image: [
'https://example.com/rentals/cottage-1.jpg',
'https://example.com/rentals/cottage-2.jpg',
],
latitude: 36.8516,
longitude: -75.9779,
containsPlace: new Accommodation(
occupancy: new QuantitativeValue(value: 4, unitCode: 'C62'),
numberOfBedrooms: 2,
numberOfBathroomsTotal: 1,
bed: [
new BedDetails(numberOfBeds: 1, typeOfBed: 'King'),
new BedDetails(numberOfBeds: 2, typeOfBed: 'Twin'),
],
),
address: new PostalAddress(
streetAddress: '1 Ocean Drive',
addressLocality: 'Virginia Beach',
addressRegion: 'VA',
postalCode: '23451',
addressCountry: 'US',
),
aggregateRating: new AggregateRating(ratingValue: 4.8, reviewCount: 95, bestRating: 5),
checkinTime: '15:00',
checkoutTime: '11:00',
description: 'A cozy cottage steps from the beach, perfect for a family getaway.',
);
$json = JsonLdGenerator::SchemaToJson(schema: $rental);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Clip;
use EvaLok\SchemaOrgJsonLd\v1\Schema\InteractionCounter;
use EvaLok\SchemaOrgJsonLd\v1\Schema\VideoObject;
$video = new VideoObject(
name: 'Getting Started with PHP 8.3',
thumbnailUrl: [
'https://example.com/thumbnails/php83-tutorial-1x1.jpg',
'https://example.com/thumbnails/php83-tutorial-16x9.jpg',
],
uploadDate: '2026-01-10',
description: 'A comprehensive introduction to the new features in PHP 8.3.',
contentUrl: 'https://example.com/videos/php83-tutorial.mp4',
embedUrl: 'https://example.com/embed/php83-tutorial',
duration: 'PT22M30S',
expires: '2027-01-10',
regionsAllowed: 'US,CA,GB',
interactionStatistic: new InteractionCounter(interactionType: 'WatchAction', userInteractionCount: 45000),
hasPart: [
new Clip(name: 'Introduction', startOffset: 0, endOffset: 120, url: 'https://example.com/videos/php83-tutorial#intro'),
],
);
$json = JsonLdGenerator::SchemaToJson(schema: $video);
use EvaLok\SchemaOrgJsonLd\v1\JsonLdGenerator;
use EvaLok\SchemaOrgJsonLd\v1\Schema\Article;
use EvaLok\SchemaOrgJsonLd\v1\Schema\BreadcrumbList;
use EvaLok\SchemaOrgJsonLd\v1\Schema\ListItem;
$article = new Article(
headline: 'How to Bake Sourdough Bread',
);
$breadcrumb = new BreadcrumbList(
itemListElement: [
new ListItem(position: 1, name: 'Recipes', item: 'https://example.com/recipes'),
new ListItem(position: 2, name: 'Bread', item: 'https://example.com/recipes/bread'),
],
);
$json = JsonLdGenerator::SchemasToJson($article, $breadcrumb);
json
{
"@context": "https://schema.org/",
"@type": "DiscussionForumPosting",
"author": {
"@type": "Person",
"name": "ForumUser42",
"url": "https://forum.example.com/users/42"
},
"datePublished": "2026-01-10T14:30:00+00:00",
"text": "What is the best way to handle database migrations in PHP?",
"headline": "Best approach for DB migrations?",
"url": "https://forum.example.com/threads/db-migrations"
}