, (*1)
Barnebys Markup Protocol
This library is a tool to generate Barnebys Markup Tags with PHP., (*2)
Requirements
PHP >= 5.6, (*3)
Installation
The recommended way is to use composer, (*4)
composer require barnebys/markup-protocol, (*5)
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., (*6)
Examples
Auction Item
Code, (*7)
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, (*8)
<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">
Fixed Price Item
Code, (*9)
// 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, (*10)
<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">