barnebys/markup-protocol

This package is abandoned and no longer maintained. No replacement package was suggested.

Barnebys Markup Protocol enhances information associated with an auction item on a webpage through key-value pairs included as <meta> elements in your HTML.

dev-master 2017-05-12 11:11 UTC

This package is auto-updated.

Last update: 2023-01-06 05:21:49 UTC


README

Latest Stable Version Build Status Coverage Status

Barnebys Markup Protocol

This library is a tool to generate Barnebys Markup Tags with PHP.

Requirements

PHP >= 5.6

Installation

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.

Examples

Auction Item

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">

Fixed Price Item

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">