1. Go to this page and download the library: Download leogout/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/ */
leogout / seo-bundle example snippets
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Leogout\Bundle\SeoBundle\LeogoutSeoBundle(),
);
}
}
class DefaultController extends Controller
{
public function indexAction()
{
$this->get('leogout_seo.provider.generator')->get('basic')
->setTitle('Title set in controller')
->setRobots(true, false); // they can be chained
return $this->render('AppBundle:Default:index.html.twig');
}
}
use Leogout\Bundle\SeoBundle\Seo\Basic\BasicSeoInterface;
class MyResource implements BasicSeoInterface
{
protected $name;
protected $description;
protected $tags = [];
// ...Your logic
// These methods are from BasicSeoInterface and have to
// return a string (or an object with a __toString() method).
public function getSeoTitle()
{
return $this->name;
}
public function getSeoDescription()
{
return $this->description;
}
public function getSeoKeywords()
{
return implode(',', $this->tags);
}
}
class MyController extends Controller
{
public function indexAction(Request $request)
{
$myResource = new MyResource();
$myResource
->setName('Cool resource')
->setDescription('Some description')
->addKeyword('hey')
->addKeyword('ho')
->addKeyword('let's go!');
$this->get('leogout_seo.provider.generator')->get('basic')->fromResource($myResource);
return $this->render('MyController:Default:index.html.twig');
}
}
use Leogout\Bundle\SeoBundle\Seo\AbstractSeoGenerator;
class MyTagsGenerator extends AbstractSeoGenerator
{
public function setMyTag($content)
{
$this->tagBuilder->addMeta('myTag')
->setType(MetaTag::NAME_TYPE)
->setValue('myAwesomeTag')
->setContent((string) $content);
return $this;
}
public function getMyTag()
{
return $this->tagBuilder->getMeta('myTag');
}
}
class MyController extends Controller
{
public function indexAction(Request $request)
{
$this->get('leogout_seo.provider.generator')->get('my_tags')->setMyTag('cool');
return $this->render('MyController:Default:index.html.twig');
}
}
twig
<head>
{{ leogout_seo() }}
</head>
twig
<head>
{{ leogout_seo('basic') }}
</head>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.