Download the PHP package spatie/schema-org without Composer

On this page you can find all versions of the php package spatie/schema-org. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
spatie/schema-org
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package schema-org

A Fluent Builder For Schema.org Types And ld+json Generator

Latest Version on Packagist GitHub Workflow Status StyleCI Total Downloads

spatie/schema-org provides a fluent builder for all Schema.org types and their properties. The code in src is generated from Schema.org's JSON-LD standards file, so it provides objects and methods for the entire core vocabulary. The classes and methods are also fully documented as a quick reference.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

Usage

All types can be instantiated through the Spatie\SchemaOrg\Schema factory class, or with the new keyword.

All types also accept arrays of the expected data type, for example sameAs accepts a string or an array of strings.

All types also implement the SPL's ArrayAccess for accessing the properties via array notation:

Types can be converted to an array or rendered to a script.

Additionally, all types can be converted to a plain JSON string by just calling json_encode() with your object:

I recommend double checking your structured data with Google's structured data testing tool.

Enumerations

As of v1.6.0, all Enumeration child types are available as classes with constants.

There's no full API documentation for types and properties. You can refer to the source or to the schema.org website.

If you don't want to break the chain of a large schema object, you can use the if method to conditionally modify the schema.

Identifier

As of v2.6.0 the identifier key is replaced by @id for simple string identifiers. This is due to the definition for the ld+json syntax.

All schema.org syntaxes already have built-in representation for URIs and URLs, e.g. in Microdata 'itemid', in RDFa 1.1, 'resource', in JSON-LD, '@id'.

schema.org/docs // PR#102 // PR#157

Advanced Usage

If you'd need to set a custom property, you can use the setProperty method.

If you'd need to retrieve a property, you can use the getProperty method. You can optionally pass in a second parameter to provide a default value.

All properties can be retrieved as an array with the getProperties method.

Multiple properties can be set at once using the addProperties method.

Context and type can be retrieved with the getContext and getType methods.

Graph - multiple items

The Graph has a lot of methods and utilities - the type-safe and simplest way is to use the overloaded methods of the Spatie\SchemaOrg\Schema class itself. These methods will get an already created or new instance of the requested schema.

With these tools the graph is a collection of all available schemas, can link these schemas with each other and prevent helper schemas from being rendered in the script-tag.

Graph Node identifiers

Sometimes you have to keep track of multiple Graph nodes of the same type - for example multiple Person nodes for different people in your Organization. To do so you are able to use node identifiers on your graph instance. If you don't provide an identifier a reserved keyword default identifier will be used.

Multi Typed Entities

Schema.org allows multi typed entities - to use them with this package you can use the MultiTypedEntity class - which works similar to the graph.

There isn't a real rule in place how the properties are merged. It only uses array_merge() behind the scenes. So you should avoid defining the same property on different types in the MTE or be sure that all properties hold the same value that it's not important which property is used at the end.

Known Issues

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of schema-org with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package spatie/schema-org contains the following files

Loading the files please wait ....