PHP code example of sergeybruhin / page-meta
1. Go to this page and download the library: Download sergeybruhin/page-meta library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sergeybruhin / page-meta example snippets
$headMeta = PageMeta::headMeta(
title: 'My Article',
description: 'Short page description',
);
$headMeta->setTitle('My Article', ' | ') // appends site name: "My Article | Site Name"
->setCanonical(route('blog.show', $post))
->setAuthor('Sergey Bruhin')
->setKeywords(['laravel', 'php', 'seo'])
->noIndex()
->noFollow();
// config/page-meta.php
return [
'globalSiteName' => 'Your Site Name',
];
$openGraph = PageMeta::openGraphArticle(
route('home'),
$page->name,
$page->description,
'Your site name',
);
$openGraph->addImage(
'https://example.com/image/url.png',
100,
100,
Image::TYPE_WEBP
);
$openGraph->addTags([
'Some tag',
'And',
'Another Tag'
]);
$openGraph->addAuthors([
'https://example.com/author/some-author',
'https://example.com/author/another',
]);
$organization = PageMeta::schemaOrganization('Your Site', route('home'))
->setDescription('Short site description')
->setTelephone('+1 555 0100')
->setEmail('[email protected] ')
->setAddress(
(new PostalAddress())
->setStreetAddress('123 Main St')
->setAddressLocality('Springfield')
->setAddressCountry('US')
)
->addSameAsMany([
'https://www.instagram.com/yoursite/',
'https://www.facebook.com/yoursite/',
]);
$website = PageMeta::schemaWebsite('Your Site', route('home'))
->setPublisher($organization);
$article = PageMeta::schemaArticle($post->name)
->setDescription($post->description)
->setImage(new ImageObject($post->cover->url, 1200, 630))
->setDatePublished($post->published_at)
->setUrl(route('blog.show', $post))
->addKeywords($post->tags->pluck('name')->all());
$breadcrumbs = PageMeta::schemaBreadcrumbList($post->breadcrumbs);
$schema = PageMeta::schemaGraph($organization, $website, $article, $breadcrumbs);
bash
php artisan vendor:publish --provider="SergeyBruhin\PageMeta\Providers\PageMetaServiceProvider" --tag="config"