budry / php-open-graph
Simple object based Open Graph generator
Installs: 31
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:libray
Requires
- php: ^7.1|^8.0
- ext-json: *
- fale/isbn: ^3.1
- respect/validation: ^1.0
Requires (Dev)
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^7.5|^8.0|^9.0
This package is auto-updated.
Last update: 2024-11-10 16:47:32 UTC
README
Simple object generator for open graph protocol. Full implementation of this specification
Installation
The best way to install budry/php-open-grap
is using Composer
$ composer require budry/php-open-grap
How to use
Create open graph instance and configure
$image = new \Budry\OpenGraph\Objects\Image("https://example.com/image.jpg"); $openGraph = new \Budry\OpenGraph\OpenGraph("Page title", "Page URL", $image); $article = new \Budry\OpenGraph\Types\Article(); $article->setExpirationDate(new DateTimeImmutable("2022-03-12 12:23:24")) ->setModifiedDate(new DateTimeImmutable()) ->setPublishedDate(new DateTimeImmutable()) ->setSection("SCI-FI") $openGraph->setType($article); foreach ($openGraph->getFields() as $field) { echo '<meta property="' . $field->getName() . '" content="' . $field->getContent() . '">' }