Download the PHP package brick/schema without Composer

On this page you can find all versions of the php package brick/schema. 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?

Informations about the package schema

Brick\Schema

A PHP library to read schema.org structured data from HTML pages.

Latest Stable Version License

Introduction

This library extracts structured data (Microdata, RDFa Lite & JSON-LD) from HTML pages using brick/structured-data, and maps any schema.org information found to IDE- and static analysis- friendly objects implementing schema.org interfaces.

Installation

This library is installable via Composer:

Requirements

This library requires PHP 7.2 or later. It makes use of the following extensions:

These extensions are enabled by default, and should be available in most PHP installations.

Project status & release process

This library is under development. It is likely to change fast in the early 0.x releases. However, the library follows a strict BC break convention:

The current releases are numbered 0.x.y. When a non-breaking change is introduced (adding new methods, fixing bugs, optimizing existing code, etc.), y is incremented.

When a breaking change is introduced, a new 0.x version cycle is always started.

It is therefore safe to lock your project to a given release cycle, such as 0.1.*.

If you need to upgrade to a newer release cycle, check the release history for a list of changes introduced by each further 0.x.0 version.

Quickstart

First of all, you need to instantiate a SchemaReader:

Then, you can proceed to reading an HTML document:

This returns an array of Thing instances, which is the base class from which all schema.org objects inherit.

All the objects returned implement Thing, but more importantly, they implement the interface(s) defined in the markup, such as Person or Product. These objects pass instanceof checks, and allow IDE autocompletion and static analysis by listing their available properties.

Schema.org interfaces live under the Brick\Schema\Interfaces namespace:

Every property of every interface, for example Person::$birthDate is an instance of SchemaTypeList, which is a container for zero or more values. Each value may be another Thing, or a plain text string.

With that in mind, let's see an example:

Note: if you're attempting to access a property that's not defined on any of the types the Thing object implements, an exception will be thrown.

Caveats

While the schema.org properties are well defined, they are designed to be quite lenient in terms of what values they accept. While they do document expected types for every property (for example, a Product's offers may only be of the Offer type), in practice this library, in accordance with the schema.org datamodel, accepts any Thing or string in any field.

You should therefore take all documented interface property types with a grain of salt, and always perform checks such as instanceof or is_string() in your code.

To quote the schema.org website:

Conformance

Although it might be helpful for search applications if structured data markup always followed schema.org very strictly, in practice this is unrealistic. Our schemas also continue to evolve in response to feedback, discussion and new applications of the data. Where possible we amend existing definitions incrementally rather than introducing lots of new properties for similar use cases. We have consequently based schema.org on a very flexible datamodel, and take a pragmatic view of conformance.

We expect schema.org properties to be used with new types, both from schema.org and from external extensions. We also expect that often, where we expect a property value of type Person, Place, Organization or some other subClassOf Thing, we will get a text string, even if our schemas don't formally document that expectation. In the spirit of "some data is better than none", search engines will often accept this markup and do the best we can. Similarly, some types such as Role and URL can be used with all properties, and we encourage this kind of experimentation amongst data consumers.


All versions of schema with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-dom Version *
brick/structured-data Version ^0.1.0
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 brick/schema contains the following files

Loading the files please wait ....