Skip to content
Generate open graph tags
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config move config to root Dec 29, 2015
src wip Mar 10, 2017
tests wip Mar 10, 2017
.editorconfig
.gitattributes initial commit Jun 4, 2015
.gitignore initial commit Jun 4, 2015
.scrutinizer.yml Update .scrutinizer.yml Jun 12, 2015
.styleci.yml Update .styleci.yml Oct 18, 2016
.travis.yml Update .travis.yml Aug 16, 2016
CHANGELOG.md Replaced placeholders Feb 17, 2017
CONTRIBUTING.md
LICENSE.md Update LICENSE.md Jan 2, 2017
README.md started on some docs Mar 9, 2017
composer.json
index.php wip Mar 10, 2017
phpunit.xml.dist

README.md

THIS DEMO IS CURRENTLY IN DEVELOPMENT, DO NOT USE.

Easily generate Open Graph tags

Latest Version on Packagist Build Status SensioLabsInsight Quality Score Total Downloads

The Open Graph protocol protocol provides a way to add rich social graphs to any webpage. It's used on websites like Facebook, Twitter, Google+ and LinkedIn.

This package provides a fluent builder for these Open Graph objects as specified in the official RDF schema.

Postcardware

You're free to use this package (it's MIT-licensed), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

The best postcards will get published on the open source page on our website.

Installation

You can install the package via composer:

composer require spatie/open-graph

Getting started

1. Set HTML prefix attribute

Every Open Graph webpage needs to specify the following prefix attribute on the <html> tag:

<html prefix="og: http://ogp.me/ns#">

2. Choose your Open Graph object type

As specified in the RDF schema every Open Graph object needs an og:type property. We've made it easy for you by providing classes for every Open Graph object you may want to generate.

og:type spatie/open-graph class
website OpenGraphWebsite
article OpenGraphArticle
book OpenGraphBook
profile OpenGraphProfile
music.song OpenGraphMusicSong
music.album OpenGraphMusicAlbum
music.playlist OpenGraphMusicPlaylist
music.radio_station OpenGraphMusicRadioStation
video.movie OpenGraphVideoMovie
video.episode OpenGraphVideoEpisode
video.tv_show OpenGraphVideoTvShow
video.other OpenGraphVideoOther

3. Generate Open Graph tags

Every OpenGraph class in this package has a create method that accepts a few required properties and a getMetatags method that returns a string of <meta> tags.

For example your webpage might feature a book. We can generate the Open Graph tags as follows:

$openGraphTags = OpenGraphBook::create('My Awesome Website', 'http://www.example.com', 'http://www.example.com/image.jpg')
    ->getMetaTags();

Open Graph types

OpenGraphWebsite

OpenGraphArticle

OpenGraphBook

OpenGraphProfile

OpenGraphMusicSong

OpenGraphMusicAlbum

OpenGraphMusicPlaylist

OpenGraphMusicRadioStation

OpenGraphVideoMovie

OpenGraphVideoEpisode

OpenGraphVideoTvShow

OpenGraphVideoOther

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.

Credits

About Spatie

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

License

The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.