This library is a tool to generate Barnebys Markup Tags with PHP.
PHP >= 5.6
The recommended way is to use composer
composer require barnebys/markup-protocol
If your project does not support composer, you can either clone the project on GitHub or download the package from here. You will then have to manually add the library to your project.
Code
use Barnebys\Protocol\Object;
use Barnebys\Protocol\Auction;
use Barnebys\Protocol\Price;
// Creates a new object
$object = new Object();
$object ->setTitle('Rolex 1956')
->setDescription('A fine watch in mint condition.')
->setURL('http://test.com/lot/1234')
->setImage('http://test.com/lot/1234.jpg')
->setCategory('watches')
->setPrice(new Price(150, 200, 'EUR'))
->setAuction(new Auction('2017-04-22T15:03:01.012345Z', '2017-08-01T15:03:01.012345Z'));
// Prints the meta tags
echo $object;
Outputs
<meta property="barnebys:title" content="Rolex 1956">
<meta property="barnebys:description" content="A fine watch in mint condition.">
<meta property="barnebys:url" content="http://test.com/lot/1234">
<meta property="barnebys:image" content="http://test.com/lot/1234.jpg">
<meta property="barnebys:category" content="watches">
<meta property="barnebys:price:amount" content="150">
<meta property="barnebys:price:bid" content="200">
<meta property="barnebys:price:currency" content="EUR">
<meta property="barnebys:auction:start" content="2017-04-22T15:03:01+00:00">
<meta property="barnebys:auction:end" content="2017-08-01T15:03:01+00:00">
Code
// Creates a new object
$object = new Object();
$object ->setTitle('Rolex 1956')
->setDescription('A fine watch in mint condition.')
->setURL('http://test.com/lot/1234')
->setImage('http://test.com/lot/1234.jpg')
->setCategory('watches')
->setSold(false)
->setPrice(new Price(150, null, 'EUR'));
// Prints the meta tags
echo $object;
Outputs
<meta property="barnebys:title" content="Rolex 1956">
<meta property="barnebys:description" content="A fine watch in mint condition.">
<meta property="barnebys:url" content="http://test.com/lot/1234">
<meta property="barnebys:image" content="http://test.com/lot/1234.jpg">
<meta property="barnebys:category" content="watches">
<meta property="barnebys:price:amount" content="150">
<meta property="barnebys:price:currency" content="EUR">
<meta property="barnebys:sold" content="0">