1. Go to this page and download the library: Download umanit/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/ */
umanit / seo-bundle example snippets
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Umanit\SeoBundle\Model\RoutableModelInterface;
#[ORM\Entity]
class Page implements RoutableModelInterface
{
// ...
}
declare(strict_types=1);
namespace App\Seo\Routable;
use App\Entity\Page;
use Umanit\SeoBundle\Handler\Routable\RoutableHandlerInterface;
use Umanit\SeoBundle\Model\RoutableModelInterface;
use Umanit\SeoBundle\Model\Route;
class PageHandler implements RoutableHandlerInterface
{
public function supports(RoutableModelInterface $entity): bool
{
return $entity instanceof Page;
}
public function process(RoutableModelInterface $entity): Route
{
return new Route('app_page_show', ['slug' => $entity->getSlug()]);
}
}
declare(strict_types=1);
namespace App\Entity;
use Umanit\SeoBundle\Doctrine\Model\SeoMetadataTrait;
use Umanit\SeoBundle\Model\HasSeoMetadataInterface;
use Umanit\SeoBundle\Model\RoutableModelInterface;
class Page implements RoutableModelInterface, HasSeoMetadataInterface
{
use SeoMetadataTrait;
// ...
}
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Umanit\SeoBundle\Model\SchemableModelInterface;
#[ORM\Entity]
class Page implements SchemableModelInterface
{
// ...
}
declare(strict_types=1);
namespace App\Seo\Schemable;
use App\Entity\Page;
use Spatie\SchemaOrg\BaseType;
use Spatie\SchemaOrg\Schema;
use Umanit\SeoBundle\Handler\Schemable\SchemableHandlerInterface;
use Umanit\SeoBundle\Model\SchemableModelInterface;
class PageHandler implements SchemableHandlerInterface
{
public function supports(SchemableModelInterface $entity): bool
{
return $entity instanceof Page;
}
/**
* @param Page $entity
*/
public function process(SchemableModelInterface $entity): BaseType
{
return Schema::mensClothingStore()
->name($entity->getName())
->url($entity->getSlug())
->contactPoint(Schema::contactPoint()->areaServed('Worldwide'))
;
}
}
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Umanit\SeoBundle\Model\BreadcrumbableModelInterface;
#[ORM\Entity]
class Page implements BreadcrumbableModelInterface
{
// ...
}
declare(strict_types=1);
namespace App\Seo\Breadcrumbable;
use App\Entity\Page;
use Umanit\SeoBundle\Handler\Breadcrumbable\BreadcrumbableHandlerInterface;
use Umanit\SeoBundle\Model\Breadcrumb;
use Umanit\SeoBundle\Model\BreadcrumbableModelInterface;
use Umanit\SeoBundle\Model\BreadcrumbItem;
class PageHandler implements BreadcrumbableHandlerInterface
{
public function supports(BreadcrumbableModelInterface $entity): bool
{
return $entity instanceof Page;
}
/**
* @param Page $entity
*/
public function process(BreadcrumbableModelInterface $entity): Breadcrumb
{
$breadcrumb = new Breadcrumb();
$breadcrumb->setItems([
new BreadcrumbItem('Homepage', '/'),
new BreadcrumbItem(
$entity->getCategory()->getName(),
$this->router->generate('app_page_category_show', ['slug' => $entity->getCategory()->getSlug()])
),
new BreadcrumbItem($entity->getName()),
]);
return $breadcrumb;
}
}
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Umanit\SeoBundle\Doctrine\Model\HistorizableUrlTrait;
use Umanit\SeoBundle\Model\HistorizableUrlModelInterface;
#[ORM\Entity]
class Page implements HistorizableUrlModelInterface
{
use HistorizableUrlTrait;
// ...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.