Skip to content

Commit a8d6c3f

Browse files
committed
update README.md
1 parent a7a591b commit a8d6c3f

File tree

2 files changed

+76
-47
lines changed

2 files changed

+76
-47
lines changed

README.md

Lines changed: 76 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,108 @@
1+
# PHP Open-Graph
2+
3+
[![Latest Version](http://img.shields.io/packagist/v/astrotomic/php-open-graph.svg?label=Release&style=for-the-badge)](https://packagist.org/packages/astrotomic/php-open-graph)
4+
[![MIT License](https://img.shields.io/github/license/Astrotomic/php-open-graph.svg?label=License&color=blue&style=for-the-badge)](https://github.com/Astrotomic/php-open-graph/blob/master/LICENSE)
5+
[![Offset Earth](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-green?style=for-the-badge)](https://plant.treeware.earth/Astrotomic/php-open-graph)
6+
7+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Astrotomic/php-open-graph/run-tests?style=flat-square&logoColor=white&logo=github&label=Tests)](https://github.com/Astrotomic/php-open-graph/actions?query=workflow%3Arun-tests)
8+
[![StyleCI](https://styleci.io/repos/82821437/shield)](https://styleci.io/repos/82821437)
9+
[![Total Downloads](https://img.shields.io/packagist/dt/astrotomic/php-open-graph.svg?label=Downloads&style=flat-square)](https://packagist.org/packages/astrotomic/php-open-graph)
10+
11+
This package provides a fluent PHP OOP builder for [Open Graph protocol](https://ogp.me).
12+
113
## Installation
214

315
You can install the package via composer:
416

5-
``` bash
6-
composer require spatie/open-graph
17+
```bash
18+
composer require astrotomic/php-open-graph
719
```
820

9-
## Getting started
21+
## Usage
1022

11-
### 1. Set HTML `prefix` attribute
23+
```php
24+
use Astrotomic\OpenGraph\OpenGraph;
25+
use Astrotomic\OpenGraph\StructuredProperties\Image;
1226

13-
Every Open Graph webpage needs to specify the following `prefix` attribute on the `<html>` tag:
27+
echo OpenGraph::website('Example')
28+
->url('https://example.com')
29+
->image('https://example.com/image1.jpg')
30+
->image(Image::make('https://example.com/image1.jpg')->width(600));
31+
```
1432

1533
```html
16-
<html prefix="og: http://ogp.me/ns#">
34+
<meta property="og:type" content="website">
35+
<meta property="og:title" content="Example">
36+
<meta property="og:url" content="https://example.com">
37+
<meta property="og:image:url" content="https://example.com/image1.jpg">
38+
<meta property="og:image:url" content="https://example.com/image1.jpg">
39+
<meta property="og:image:width" content="600">
1740
```
1841

19-
### 2. Choose your Open Graph object type
42+
### Types
2043

21-
As specified in the [RDF schema](http://ogp.me/ns/ogp.me.ttl) 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.
44+
#### Global
2245

23-
| og:type | spatie/open-graph class |
24-
|-----------------------|------------------------------|
25-
| `website` | `OpenGraphWebsite` |
26-
| `article` | `OpenGraphArticle` |
27-
| `book` | `OpenGraphBook` |
28-
| `profile` | `OpenGraphProfile` |
29-
| `music.song` | `OpenGraphMusicSong` |
30-
| `music.album` | `OpenGraphMusicAlbum` |
31-
| `music.playlist` | `OpenGraphMusicPlaylist` |
32-
| `music.radio_station` | `OpenGraphMusicRadioStation` |
33-
| `video.movie` | `OpenGraphVideoMovie` |
34-
| `video.episode` | `OpenGraphVideoEpisode` |
35-
| `video.tv_show` | `OpenGraphVideoTvShow` |
36-
| `video.other` | `OpenGraphVideoOther` |
46+
* `\Astrotomic\OpenGraph\Types\Website`
47+
* `\Astrotomic\OpenGraph\Types\Article`
48+
* `\Astrotomic\OpenGraph\Types\Profile`
49+
* `\Astrotomic\OpenGraph\Types\Book`
3750

38-
### 3. Generate Open Graph tags
51+
#### Music
3952

40-
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.
53+
* `\Astrotomic\OpenGraph\Types\Music\Album`
54+
* `\Astrotomic\OpenGraph\Types\Music\Playlist`
55+
* `\Astrotomic\OpenGraph\Types\Music\Song`
56+
* `\Astrotomic\OpenGraph\Types\Music\RadioStation`
4157

42-
For example your webpage might feature a book. We can generate the Open Graph tags as follows:
58+
#### Video
4359

44-
```php
45-
$openGraphTags = OpenGraphBook::create('My Awesome Website', 'http://www.example.com', 'http://www.example.com/image.jpg')
46-
->getMetaTags();
60+
* `\Astrotomic\OpenGraph\Types\Video\Movie`
61+
* `\Astrotomic\OpenGraph\Types\Video\TvShow`
62+
* `\Astrotomic\OpenGraph\Types\Video\Episode`
63+
* `\Astrotomic\OpenGraph\Types\Video\Other`
64+
65+
### Structured Properties
66+
67+
* `\Astrotomic\OpenGraph\StructuredProperties\Image`
68+
* `\Astrotomic\OpenGraph\StructuredProperties\Video`
69+
* `\Astrotomic\OpenGraph\StructuredProperties\Audio`
70+
71+
## Testing
72+
73+
``` bash
74+
composer test
4775
```
4876

49-
## Open Graph types
77+
## Changelog
78+
79+
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
80+
81+
## Contributing
82+
83+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
5084

51-
### `OpenGraphWebsite`
85+
### Security
5286

53-
### `OpenGraphArticle`
87+
If you discover any security related issues, please email dev@astrotomic.info instead of using the issue tracker.
5488

55-
### `OpenGraphBook`
89+
## Credits
5690

57-
### `OpenGraphProfile`
91+
- [Tom Witkowski](https://github.com/Gummibeer)
92+
- [Alex Vanderbist](https://github.com/AlexVanderbist)
93+
- [All Contributors](../../contributors)
5894

59-
### `OpenGraphMusicSong`
95+
## License
6096

61-
### `OpenGraphMusicAlbum`
97+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
6298

63-
### `OpenGraphMusicPlaylist`
99+
## Treeware
64100

65-
### `OpenGraphMusicRadioStation`
101+
You're free to use this package, but if it makes it to your production environment I would highly appreciate you buying the world a tree.
66102

67-
### `OpenGraphVideoMovie`
103+
It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to [plant trees](https://www.bbc.co.uk/news/science-environment-48870920). If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.
68104

69-
### `OpenGraphVideoEpisode`
105+
You can buy trees at [offset.earth/treeware](https://plant.treeware.earth/Astrotomic/php-open-graph)
70106

71-
### `OpenGraphVideoTvShow`
107+
Read more about Treeware at https://treeware.earth
72108

73-
### `OpenGraphVideoOther`

composer.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
"email": "gummibeer@astrotomic.info",
1313
"homepage": "https://astrotomic.info",
1414
"role": "Developer"
15-
},
16-
{
17-
"name": "Alex Vanderbist",
18-
"email": "alex.vanderbist@gmail.com",
19-
"homepage": "https://spatie.be",
20-
"role": "Developer"
2115
}
2216
],
2317
"require": {

0 commit comments

Comments
 (0)