1. Go to this page and download the library: Download timurturdyev/simple-seo 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/ */
timurturdyev / simple-seo example snippets
seo()->title('Кресло руководителя EX-500')
->description('Эргономичное кресло с кожаным сиденьем.')
->image('https://example.com/chair.jpg')
->canonical('https://example.com/catalog/chairs/ex-500');
final class Product extends Model implements HasSeo
{
public function toSeo(): SeoData
{
return new SeoData(
title: $this->name,
description: $this->summary,
image: $this->cover_url,
canonical: route('products.show', $this),
ogType: 'product',
jsonLd: [Schema::product()->name($this->name)->sku($this->sku)],
);
}
}
seo()->apply($product);
use TimurTurdyev\SimpleSeo\JsonLd\JsonLdBuilder;
use TimurTurdyev\SimpleSeo\Meta\MetaBuilder;
use TimurTurdyev\SimpleSeo\OpenGraph\OpenGraphBuilder;
use TimurTurdyev\SimpleSeo\SeoManager;
use TimurTurdyev\SimpleSeo\TwitterCard\TwitterCardBuilder;
$seo = new SeoManager(
new MetaBuilder(defaultTitle: 'Мой сайт', titleSuffix: ' - Мой сайт'),
new OpenGraphBuilder(defaultSiteName: 'Мой сайт', defaultType: 'website', defaultLocale: 'ru_RU'),
new TwitterCardBuilder(),
new JsonLdBuilder(),
);