Get microdata from web page and check each type found with!

1.1 2014-02-27 12:38 UTC


Get microdata from web page !


You can install this lib using Composer or by cloning this repository.

By using Composer, just add following lines into your composer.json file and run composer update:

    "require": {
        "malenki/microdata": "dev-master"

By cloning this repository, just do git clone

Coding using the library

With this library, you get microdata as tree object.

You can get microdata from given URL or given content as string:

use \Malenki\Microdata;
$md = new Microdata('');
$md = new Microdata($some_content, Microdata::AS_STRING);

In string context, print the JSON microdata tree:

use \Malenki\Microdata;
$md = new Microdata('');

You can get statistical data about amount of types found:

use \Malenki\Microdata;
$md = new Microdata('');

Now, you can check microdata with schemas defined on <> using their JSON definition type from website or from your own JSON file stored on your file system.

use \Malenki\Microdata;
$md = new Microdata('');
$md->availableChecking(); // no arg: it takes JSON from official website
$md->availableChecking('all.json'); // arg: it takes JSON from file system
print($md); // If errors found, they will be present into the returned JSON

Using CLI app

This library comes with a small CLI application too.

Its use is simple. If you have not idea how to used it, just do bin/microdata --help or read following lines.

To get microdata from an URL, do:

$ bin/microdata 'http://some.url/path/'

Same as previous but getting JSON in place:

$ bin/microdata --json 'http://some.url/path/'

You can request checking too (only schemas defined on

$ bin/microdata --check 'http://some.url/path/'

Same as previous but with a JSON schema on local filesystem:

$ bin/microdata --check --check-file foo.json 'http://some.url/path/'

You can even use pipe or standard input too:

$ echo '<p itemscope itemtype=""><span itemprop="name">Truc</span></p>' | bin/microdata --pipe


You must have PHP 5.3+ and DOM extension loaded.


This lib is based on work of Philip Jägenstedt and Lin Clark.