Api Platform conference
Register now

schema is a command-line tool part of the API Platform framework that instantly generates a set of PHP classes from RDF vocabularies such as (but not limited to) Schema.org or ActivityStreams. Alternatively, it can generate PHP classes from an OpenAPI documentation.

Find and browse (or create) a vocabulary that fits your needs, choose the types and properties you need, run our code generator and you’re done! Alternatively, design your API with tools like Stoplight, export the OpenAPI documentation, run our code generator and your API is ready!

Stoplight

You get a fully featured PHP data model including:

  • A set of PHP entities with properties, constants (enum values), getters, setters, adders and removers. The class hierarchy provided by the vocabulary will be translated to a PHP class hierarchy with parents as abstract classes. The generated code complies with PSR coding standards;
  • Full, high-quality PHPDoc and type declarations for classes, properties, constants and methods extracted from the vocabulary;
  • Doctrine ORM or MongoDB ODM attributes mapping including database columns / fields with type guessing, relations with cardinality guessing, smart class inheritance (through the #[MappedSuperclass] or #[InheritanceType] attributes depending on if the resource is used in a relation);
  • Data validation through Symfony Validator attributes including enum support (choices) and check for required properties;
  • API Platform attributes;
  • Interfaces and Doctrine ResolveTargetEntityListener support;
  • Custom PHP namespace support;
  • List of values provided the vocabulary with PHP Enum classes.

Bonus:

  • The code generator is fully configurable and extendable. All features can be deactivated (e.g., the Doctrine mapping generator) and a custom generator can be added;
  • The code generator can load previously generated files and add new changes while keeping the user-added ones;
  • The generated code can be used as is in a Symfony app (but it will work too in a raw PHP project or any other framework including Laravel and Zend Framework).

# What Is Schema.org?

Schema.org is a vocabulary representing common data structures and their relations. Schema.org can be exposed as JSON-LD, microdata and RDF. Extracting semantical data exposed in the Schema.org vocabulary is supported by a growing number of companies including Google (Search, Gmail), Yahoo!, Bing and Yandex.

# Why Use Schema.org Data to Generate a PHP Model?