Download the PHP package palex/phpstructureddata without Composer

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

PHPStructuredData Build Status

A set of PHP libraries that use the http://schema.org vocabulary to implement and output Microdata or RDFa Lite 1.1 semantics.
This library is used in the Joomla CMS since version 3.2 (called JMicrodata).
Created during the Google Summer of Code 2013 and 2014.

Quick overview

The library was designed with this goals in mind:

  1. Having the possibility to switch between Microdata and RDFa Lite 1.1 semantics.
  2. Having the possibility to switch the Type dynamically, you just change the Type (there are more than 550+ different available Types).
  3. Display validated semantics, the library takes care of displaying data in the correct format (e.g. all the dates in the ISO standard).
  4. Enable/disable the library output.
  5. Fallbacks, you should never lose any meaningful semantic (e.g. if you change the Type and it does not have an author Property, it will fallback to the Person Type with the name Property).

Class diagram

Class Diagram

Installation

Usage Example

Let's suppose that you already have an instance of the Microdata or RDFa library. And you need to add Microdata or RDFa semantics to the following HTML which is part of an article (e.g. ).

The library will render:

The library will render:

Instead, if you decide to change the current Type (e.g. ).
The library will render:

The library will render:

As you can see fallbacks to the Person Type, and there is no loss of information, even if the current Type doesn't have an author Property it will display important information for the machines, search engines know that there is a Person .
Instead, if you decide to not render Microdata or RDFa semantics, you just disable the library output (e.g. ).
Both and library will render:

Currently both and library doesn't support multiple fallbacks.

ParserPlugin

If you want to keep your views separated from the logic, is a PHP class for parsing the HTML markup and converting the HTML5 attributes into the correctly formatted Microdata or RDFa Lite 1.1 semantics.

The attributes are new in HTML5, they gives us the ability to embed custom data attributes on all HTML elements. So if you disable the library output, the HTML will still be validated. The default suffix the library will search for is , where sd stands for structured data, but you can register more than one custom suffix.

Markup Syntax

setType

ParserPlugin Syntax
The type defines which schema is being used for the following markup. The Type must always have the first character Uppercase to be correctly interpreted. If the type is a valid schema, the global scope for the page from this point onwards is updated to this schema. The plugin will replace the data tag with in case of Microdata semantics or in case of RDFa Lite 1.1 semantics.

Example:

This will be output using semantics as:

Or using semantics as:

Specifying generic item properties

ParserPlugin Syntax
Once a schema has been declared, the next step is to declare individual properties – explaining the content and giving it semantic meaning.

The property must always have the first character as lowercase to be correctly interpreted. If the property is found to be part of the current schema, the plugin will replace the data tag with in case of Microdata semantics or in case of RDFa Lite 1.1 semantics. If the property is not found to be a valid property of the active schema, it will be ignored and the next available property will be parsed.

Example:

This will be output using semantics as:

Or using semantics as:

Specifying schema—dependant item properties

ParserPlugin Syntax
Sometimes you may want to explicitly state a property which should only be used when a specific schema is active – for example, if the property has a specific property in one schema, which is called something different in another schema.

It is possible to achieve this by using a schema–dependant property. This works by using a combination between both Type and property, separated by a full stop. In short, if the current global scope is equal to Type and the property is part of that Type, the plugin will replace the data tag with in case of Microdata semantics or in case of RDFa Lite 1.1.

Example:

This will be output using semantics as:

Or using semantics as:

Using multiple properties

ParserPlugin Syntax
It is possible, using a combination of these, to specify multiple properties including some which are specific for a schema and others which are generic. The order of the building blocks isn't significant and a white space is used as a separator.

Example:

This will be output using semantics as:

Or using semantics as:

Nesting schemas

Sometimes it is necessary to nest schemas – for example if you want to describe a person when you have the Article schema open. This is possible using nested schemas. To use this, simply append the schema preceeded by a full stop, after the property. Once you have finished using the nested schema, close the containing tag, and re-set the original schema.

Example:

This will be output using semantics as:

Or using semantics as:

The Algorithm:
  1. First the parser checks for setTypes. If one or more matches are found then the current global scope will be updated with the first match. At this point if there are no specific or generic properties the algorithm will finish and replace the data tag with the specified scope. Otherwise continue to point 2.
  2. The parser checks for specific item properties. If one or more valid matches are found, then the algorithm will finish and replace the data tag with the first match property. Otherwise go to point 3
  3. The parser checks for generic properties. If one or more valid matches are found, then the algorithm will replace the data tag with the first property that is matched, and complete the algorithm.

Usage Example

Let's suppose that you already have an instance of the library. And you need to add Microdata or RDFa semantics to the following HTML which is part of an article (e.g. ).

The output will be:

The output will be:

Instead, if you decide to change the current Type (e.g. ).
The output will be:

The output will be:

Documentation

libraries use the file to check and output validated semantics, that file contains all the available Types and Properties from the http://schema.org vocabulary, and it was generated automatically with the https://github.com/alexprut/Spider4Schema web crawler.

Todos

StructuredData

License

PHPStructuredData is licensed under the MIT License – see the LICENSE file for details.


All versions of phpstructureddata with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 palex/phpstructureddata contains the following files

Loading the files please wait ....