1. Go to this page and download the library: Download yapro/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/ */
yapro / seo-bundle example snippets
class MyController extends AbstractController
{
/**
* @Route("/article/{id}", methods={"GET"})
*/
public function article(
Article $article
ContentManager $contentManager
): Response {
$textWithSeoLinks = $contentManager->getSafeHtmlWithSeoLinks($article->getText());
return new Response($textWithSeoLinks);
}
}
/**
* @Route("/redirect/page", methods={"GET"})
*/
public function seoRedirect(Request $request, LinkManager $linkManager): Response
{
$redirect = $linkManager->getRedirect($request->getRequestUri());
if ($redirect->getHttpStatus() === 200) {
return new Response('<META HTTP-EQUIV="Refresh" CONTENT="0; URL=' . $redirect->getUrl() . '">', 404);
}
throw $this->createNotFoundException('Redirect page not found');
}