The Schema Generator

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.

schema は、Schema.org や ActivityStreams などの RDF 語彙 (ただしこれらに限定されません) から一連の PHP クラスを即座に生成する API プラットフォーム フレームワークのコマンド ライン ツールの一部です。また、OpenAPI ドキュメントから PHP クラスを生成することもできます。

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 などのツールを使用して API を設計し、OpenAPI ドキュメントをエクスポートして、コードを実行します。ジェネレーターと API の準備ができました!

Stoplight

You get a fully featured PHP data model including:

以下を含む完全な機能を備えた PHP データ モデルを取得します。

  • 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;
    プロパティ、定数 (列挙値)、getter、setter、adder、および remover を含む一連の PHP エンティティ。ボキャブラリーによって提供されるクラス階層は、抽象クラスとしての親を持つ PHP クラス階層に変換されます。生成されたコードは、PSR コーディング標準に準拠しています。
  • Full, high-quality PHPDoc and type declarations for classes, properties, constants and methods extracted from the vocabulary;
    クラス、プロパティ、定数、および語彙から抽出されたメソッドの完全で高品質な PHPDoc および型宣言。
  • 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);
    Doctrine ORM または MongoDB ODM 属性マッピング (リソースがリレーションで使用されているかどうかに応じて、#[MappedSuperclass] または #[InheritanceType] 属性による) 型推測によるデータベース列/フィールド、カーディナリティ推測によるリレーションを含むリレーション。
  • Data validation through Symfony Validator attributes including enum support (choices) and check for required properties;
    Symfony Validator 属性によるデータ検証 (列挙サポート (選択肢) や必要なプロパティのチェックなど)。
  • API Platform attributes;
    API プラットフォームの属性。
  • Interfaces and Doctrine ResolveTargetEntityListener support;
    インターフェイスと Doctrine ResolveTargetEntityListener のサポート。
  • Custom PHP namespace support;
    カスタム PHP 名前空間のサポート。
  • List of values provided the vocabulary with PHP Enum classes.
    PHP Enum クラスで語彙を提供する値のリスト。

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;
    コード ジェネレーターは、完全に構成可能で拡張可能です。すべての機能を無効にすることができ (Doctrine マッピング ジェネレーターなど)、カスタム ジェネレーターを追加できます。
  • 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).
    生成されたコードは、Symfony アプリでそのまま使用できます (ただし、Laravel や Zend Framework を含む他のフレームワークの生の PHP プロジェクターでも機能します)。

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.

Schema.org は、一般的なデータ構造とその関係を表す語彙です。 Schema.org は、JSON-LD、microdata、および RDF として公開できます。Schema.org ボキャブラリーで公開されたセマンティック データの抽出は、Google (検索、Gmail)、Yahoo!、Bing、Yandex など、ますます多くの企業によってサポートされています。

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

Don't Reinvent the Wheel

Data models provided by Schema.org are popular and were proven efficient. They cover a broad spectrum of topics including creative works, e-commerce, events, medicine, social networking, people, postal addresses, organization data, places or reviews. Schema.org has its root in a ton of preexisting well-designed vocabularies and is successfully used by more and more websites and applications.

Schema.org が提供するデータ モデルは人気があり、効率的であることが証明されています。それらは、クリエイティブ作品、電子商取引、イベント、医学、ソーシャル ネットワーキング、人物、住所、組織データ、場所、またはレビューなど、幅広いトピックをカバーしています。ますます多くの Web サイトやアプリケーションで使用されています。

Pick schemas applicable to your application, generate your PHP model, then customize and specialize it to fit your needs.

アプリケーションに適用可能なスキーマを選択し、PHP モデルを生成してから、ニーズに合わせてカスタマイズおよび特化します。

Improve SEO and User Experience

Adding Schema.org markup to websites and apps increases their ranking in search engines results and enables awesome features such as Google Rich Snippets and Gmail markup.

Web サイトやアプリに Schema.org マークアップを追加すると、検索エンジンの結果でのランキングが上がり、Google リッチ スニペットや Gmail マークアップなどの優れた機能が有効になります。

Mapping your app data model to Schema.org structures can be tedious. When using the generator, your data model will be derived from Schema.org. Adding microdata markup to your templates or serializing your data as JSON-LD will not require specific mapping nor adaptation. It's a matter of minutes.

アプリのデータ モデルを Schema.org 構造にマッピングするのは面倒な場合があります。ジェネレーターを使用する場合、データ モデルは Schema.org から派生します。テンプレートに microdata マークアップを追加したり、JSON-LD としてデータをシリアライズしたりする場合、特定のマッピングや適応は必要ありません。ほんの数分です。

Be Ready for The Future

Schema.org improves the interoperability of your applications. Used with hypermedia technologies such as Hydra it's a big step towards the semantic and machine-readable web. It opens the way to generic web API clients able to extract and process data from any website or app using such technologies.

Schema.org は、アプリケーションの相互運用性を向上させます。 Hydrait などのハイパーメディア テクノロジと併用することは、セマンティックで機械可読な Web に向けた大きな一歩です。このようなテクノロジを使用して、任意の Web サイトまたはアプリからデータを抽出および処理できる汎用 Web API クライアントへの道が開かれます。

Documentation