PHPackages                             inesta/php-schemas - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. inesta/php-schemas

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

inesta/php-schemas
==================

A fluent, type-safe PHP library for creating Schema.org structured data (JSON-LD, Microdata, RDFa)

v0.1.0(11mo ago)01MITPHPPHP ^8.3CI passing

Since Jun 7Pushed 11mo agoCompare

[ Source](https://github.com/Inesta/php-schemas)[ Packagist](https://packagist.org/packages/inesta/php-schemas)[ Docs](https://github.com/inesta/php-schemas)[ RSS](/packages/inesta-php-schemas/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (11)Versions (2)Used By (0)

PHP Schema.org Library
======================

[](#php-schemaorg-library)

[![PHP Version](https://camo.githubusercontent.com/e69fc10ad0d3845d44d08b0eeedd6dd7a5bfa4ab872e68e26b131554122d35d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c75652e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE.md)[![PHPStan Level](https://camo.githubusercontent.com/1bc07920f0d36e55c17e1d38b1caa132cc605f51a82b388c962870b9a747b898/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e737667)](https://phpstan.org/)[![Tests](https://camo.githubusercontent.com/d2c8565e4b9409a8bd9f76647ceadf4711c431875e286c94ae3ce342367dfae3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d32303325323070617373696e672d627269676874677265656e2e737667)](#testing)[![Code Coverage](https://camo.githubusercontent.com/b3545ae1bcdb4ea486f71f87b43001e82dd21933bc8035d44601706c851265da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e737667)](#testing)[![Packagist Version](https://camo.githubusercontent.com/1794d4e5f41216ad5cf7050a59eaea152f7a033d8e5151f004e951e321a834d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e657374612f7068702d736368656d61732e737667)](https://packagist.org/packages/inesta/php-schemas)[![Downloads](https://camo.githubusercontent.com/8fcecaca89105bfe9bbccf0ff342c602bb3734b0513aec580e576d92477b1743/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e657374612f7068702d736368656d61732e737667)](https://packagist.org/packages/inesta/php-schemas)

A modern, type-safe PHP library for creating Schema.org structured data with fluent interfaces and comprehensive validation. Generate JSON-LD, Microdata, and RDFa markup to improve SEO and enable rich snippets.

Features
--------

[](#features)

### 🛡️ Type Safety First

[](#️-type-safety-first)

- Every Schema.org type is a strongly-typed PHP class
- Full PHPStan Level 9 compliance
- Rich IDE autocomplete and error detection

### 🔄 Immutable Objects

[](#-immutable-objects)

- All schema objects are immutable by design
- Modifications return new instances
- Thread-safe and predictable behavior

### 🔧 Fluent Interface

[](#-fluent-interface)

- Builder pattern with chainable methods
- Intuitive and readable API
- IDE-friendly method chaining

### 📊 Multiple Output Formats

[](#-multiple-output-formats)

- **JSON-LD** - Perfect for search engines and rich snippets
- **Microdata** - Inline HTML markup with schema data
- **RDFa** - Semantic web standard markup

### ✅ Comprehensive Validation

[](#-comprehensive-validation)

- Built-in Schema.org compliance checking
- Pluggable validation rules system
- Required property validation
- Type safety validation

### 🎯 Framework Integration

[](#-framework-integration)

- Laravel service provider and facades
- Symfony bundle support
- PSR-4 autoloading compatible

Installation
------------

[](#installation)

Install via Composer:

```
composer require inesta/php-schemas
```

### Requirements

[](#requirements)

- PHP 8.3 or higher
- JSON extension
- mbstring extension (recommended)

### ⚡ Performance Features

[](#-performance-features)

- **Schema Caching** - Automatic caching for frequently used schemas
- **Lazy Loading** - Defer schema creation until actually needed
- **Memory Optimization** - Efficient memory usage for large schema collections
- **Benchmarking Tools** - Built-in performance measurement utilities

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use Inesta\Schemas\Builder\Factory\SchemaFactory;

// Create a simple schema
$article = SchemaFactory::create('Article', [
    'headline' => 'How to Use Schema.org in PHP',
    'author' => 'John Doe',
    'datePublished' => '2024-01-15',
    'description' => 'A comprehensive guide to implementing Schema.org in PHP applications.',
]);

// Render as JSON-LD
echo $article->toJsonLd();
```

### Using Builders (Recommended)

[](#using-builders-recommended)

```
use Inesta\Schemas\Builder\Builders\ArticleBuilder;
use Inesta\Schemas\Builder\Builders\PersonBuilder;

// Create a person
$author = PersonBuilder::create()
    ->name('John Doe')
    ->email('john@example.com')
    ->url('https://johndoe.com')
    ->build();

// Create an article with the author
$article = ArticleBuilder::create()
    ->headline('Advanced PHP Techniques')
    ->description('Learn advanced PHP programming techniques.')
    ->author($author)
    ->datePublished('2024-01-15')
    ->keywords(['php', 'programming', 'tutorial'])
    ->build();
```

### Rendering Output

[](#rendering-output)

#### JSON-LD (Recommended for SEO)

[](#json-ld-recommended-for-seo)

```
use Inesta\Schemas\Renderer\JsonLd\JsonLdRenderer;

$renderer = new JsonLdRenderer();
$renderer
    ->setPrettyPrint(true)
    ->setIncludeScriptTag(true);

echo $renderer->render($article);
```

Output:

```

{
    "@context": "https://schema.org",
    "@type": "Article",
    "headline": "Advanced PHP Techniques",
    "description": "Learn advanced PHP programming techniques.",
    "author": {
        "@type": "Person",
        "name": "John Doe",
        "email": "john@example.com",
        "url": "https://johndoe.com"
    },
    "datePublished": "2024-01-15",
    "keywords": ["php", "programming", "tutorial"]
}

```

#### Microdata

[](#microdata)

```
use Inesta\Schemas\Renderer\Microdata\MicrodataRenderer;

$renderer = new MicrodataRenderer();
$renderer
    ->setUseSemanticElements(true)
    ->setIncludeMetaElements(true);

echo $renderer->render($article);
```

Output:

```

  Advanced PHP Techniques
  Learn advanced PHP programming techniques.

    John Doe
    john@example.com
    https://johndoe.com

```

#### RDFa

[](#rdfa)

```
use Inesta\Schemas\Renderer\Rdfa\RdfaRenderer;

$renderer = new RdfaRenderer();
$renderer
    ->setUseSemanticElements(true)
    ->setPrettyPrint(true);

echo $renderer->render($article);
```

Validation
----------

[](#validation)

The library includes a comprehensive validation system:

```
use Inesta\Schemas\Validation\ValidationEngine;
use Inesta\Schemas\Validation\Rules\RequiredPropertiesRule;
use Inesta\Schemas\Validation\Rules\PropertyTypesRule;

$validator = new ValidationEngine();
$validator
    ->addRule(new RequiredPropertiesRule())
    ->addRule(new PropertyTypesRule());

$result = $validator->validate($article);

if (!$result->isValid()) {
    foreach ($result->getErrors() as $error) {
        echo "Error: {$error->getMessage()}\n";
    }
}
```

Supported Schema Types
----------------------

[](#supported-schema-types)

Currently supported Schema.org types:

- **Thing** - Base type for all schemas
- **Article** - News articles, blog posts, etc.
- **Person** - Individual people
- **Organization** - Companies, institutions, etc.

More types coming soon! The library is designed to be easily extensible.

Advanced Usage
--------------

[](#advanced-usage)

### Custom Validation Rules

[](#custom-validation-rules)

```
use Inesta\Schemas\Validation\Interfaces\ValidationRuleInterface;
use Inesta\Schemas\Validation\ValidationResult;

class CustomValidationRule implements ValidationRuleInterface
{
    public function validate(SchemaTypeInterface $schema): ValidationResult
    {
        // Your custom validation logic
        return new ValidationResult(true);
    }

    public function getPriority(): int
    {
        return 100;
    }
}

$validator->addRule(new CustomValidationRule());
```

### Framework Integration

[](#framework-integration)

#### Laravel

[](#laravel)

```
// config/app.php
'providers' => [
    // ...
    Inesta\Schemas\Adapters\Laravel\SchemaServiceProvider::class,
],

'aliases' => [
    // ...
    'Schema' => Inesta\Schemas\Adapters\Laravel\Facades\Schema::class,
],
```

```
// Usage in Laravel
$article = Schema::article()
    ->headline('Laravel and Schema.org')
    ->description('Integrating Schema.org with Laravel applications.')
    ->build();
```

#### Symfony

[](#symfony)

```
// config/bundles.php
return [
    // ...
    Inesta\Schemas\Adapters\Symfony\SchemaBundle::class => ['all' => true],
];
```

Testing
-------

[](#testing)

Run the test suite:

```
# Run all tests
composer test

# Run with coverage
composer test:coverage

# Run specific test suites
composer test:unit
composer test:integration
composer test:compliance
```

Quality Assurance
-----------------

[](#quality-assurance)

This project maintains high code quality standards:

```
# Static analysis (PHPStan Level 9)
composer analyse

# Code style (PSR-12)
composer cs:check
composer cs:fix

# All quality checks
composer check-all
```

Contributing
------------

[](#contributing)

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

### Development Setup

[](#development-setup)

1. Clone the repository
2. Install dependencies: `composer install`
3. Run tests: `composer test`
4. Check code quality: `composer check-all`

Security
--------

[](#security)

Please review our [Security Policy](SECURITY.md) for reporting vulnerabilities.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for version history and changes.

License
-------

[](#license)

This project is licensed under the MIT License - see [LICENSE.md](LICENSE.md) for details.

Acknowledgments
---------------

[](#acknowledgments)

- [Schema.org](https://schema.org/) for the vocabulary specification
- The PHP community for excellent tooling and standards
- All contributors to this project

Credits
-------

[](#credits)

- [Roel Veldhuizen](https://roelveldhuizen.com)
- [Inesta.nl](https://inesta.nl)
- [All Contributors](../../contributors)

---

**Need help?** Check out our [documentation](docs/) or [open an issue](https://github.com/inesta/php-schemas/issues).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance51

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

345d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4c794d505195b946ec145fce2c7a2c8a1034a56ba986009c6dec26d14b0a575?d=identicon)[roelveldhuizen](/maintainers/roelveldhuizen)

---

Top Contributors

[![roelveldhuizen](https://avatars.githubusercontent.com/u/1481741?v=4)](https://github.com/roelveldhuizen "roelveldhuizen (21 commits)")

---

Tags

webschema-sJSON-LDseordfastructured-dataschema.orgmicrodatarich-snippets

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/inesta-php-schemas/health.svg)

```
[![Health](https://phpackages.com/badges/inesta-php-schemas/health.svg)](https://phpackages.com/packages/inesta-php-schemas)
```

###  Alternatives

[artesaos/seotools

SEO Tools for Laravel and Lumen

3.3k5.1M60](/packages/artesaos-seotools)[brotkrueml/schema

Embedding schema.org vocabulary - API and view helpers for schema.org markup

33584.6k13](/packages/brotkrueml-schema)[brick/schema

Schema.org library for PHP

5163.7k1](/packages/brick-schema)[torann/json-ld

Extremely simple JSON-LD markup generator.

149620.7k1](/packages/torann-json-ld)[honeystone/laravel-seo

SEO metadata and JSON-LD package for Laravel.

34744.1k](/packages/honeystone-laravel-seo)[brick/structured-data

Microdata, RDFa Lite &amp; JSON-LD structured data reader

26162.8k1](/packages/brick-structured-data)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
