1. Go to this page and download the library: Download mulertech/seo-bundle 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/ */
mulertech / seo-bundle example snippets
use MulerTech\SeoBundle\Model\SeoCompanyInfoProviderInterface;
class CompanyInfoProvider implements SeoCompanyInfoProviderInterface
{
public function getName(): string { return 'My Company'; }
public function getWebsite(): string { return 'https://mycompany.com'; }
public function getEmail(): string { return '[email protected]'; }
public function getPhone(): string { return '+33 1 23 45 67 89'; }
public function getPostalCode(): string { return '14000'; }
public function getCity(): string { return 'Caen'; }
public function getCountry(): string { return 'France'; }
public function getSocialUrls(): array {
return [
'linkedin' => 'https://linkedin.com/company/mycompany',
'github' => 'https://github.com/mycompany',
];
}
}
use MulerTech\SeoBundle\Service\MetaTagService;
class HomeController extends AbstractController
{
public function index(MetaTagService $metaTagService): Response
{
$seo = $metaTagService->generateMetaTags([
'title' => 'Welcome to My Company',
'description' => 'We build amazing web applications.',
]);
return $this->render('home/index.html.twig', ['seo' => $seo]);
}
}
use MulerTech\SeoBundle\Model\BlogPostingSeoInterface;
class BlogPost implements BlogPostingSeoInterface
{
public function getSeoTitle(): string { return $this->title; }
public function getSeoExcerpt(): ?string { return $this->excerpt; }
public function getSeoAuthorName(): string { return $this->author->getFullName(); }
public function getSeoPublishedAt(): ?string { return $this->publishedAt?->toIso8601String(); }
public function getSeoUpdatedAt(): ?string { return $this->updatedAt?->toIso8601String(); }
}
use MulerTech\SeoBundle\Model\SitemapUrl;
use MulerTech\SeoBundle\Model\SitemapUrlProviderInterface;
class BlogSitemapProvider implements SitemapUrlProviderInterface
{
public function __construct(
private readonly BlogPostRepository $repository,
private readonly UrlGeneratorInterface $urlGenerator,
) {}
public function getUrls(): iterable
{
foreach ($this->repository->findPublished() as $post) {
yield new SitemapUrl(
loc: $this->urlGenerator->generate('app_blog_show', ['slug' => $post->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
priority: '0.6',
changefreq: 'monthly',
lastmod: $post->getUpdatedAt()?->toIso8601String(),
);
}
}
}
use MulerTech\SeoBundle\Model\LlmsLink;
use MulerTech\SeoBundle\Model\LlmsSection;
use MulerTech\SeoBundle\Model\LlmsSectionProviderInterface;
class BlogLlmsProvider implements LlmsSectionProviderInterface
{
public function __construct(
private readonly BlogPostRepository $repository,
private readonly UrlGeneratorInterface $urlGenerator,
) {}
public function getSections(): iterable
{
$links = [];
foreach ($this->repository->findPublished() as $post) {
$links[] = new LlmsLink(
url: $this->urlGenerator->generate('app_blog_show', ['slug' => $post->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
title: $post->getTitle(),
description: $post->getExcerpt(),
);
}
yield new LlmsSection('Blog', $links);
}
}
use MulerTech\SeoBundle\Model\SeoFieldsTrait;
class BlogPost
{
use SeoFieldsTrait;
// Adds: metaDescription, metaKeywords with getters/setters
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.