PHP code example of abdellahramadan / seo-bundle

1. Go to this page and download the library: Download abdellahramadan/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/ */

    

abdellahramadan / seo-bundle example snippets


// config/bundles.php

return [
    // ...
    Abdellahramadan\SeoBundle\SeoBundle::class => ['all' => true],
];

use Abdellahramadan\SeoBundle\Metas\MetaTagsManagerInterface;


public function myController(MetaTagsManagerInterface $metaTags): Response 
{
    $metaTags->setTitle('My Title')
        ->setDescription('This is the description of the page')
        ->setKeywords(['keywords', 'seo', 'meta'])
        ->setCanonical('https://canonical.com')
    ;
}

{{ meta_tags(title: 'My Title', description: 'This is the description of the page' ...)}

<head>
    {{ meta_tags() }}
</head>


use Abdellahramadan\OpenGraphBundle\OpenGraph\OpenGraphManagerInterface;

class HomeController extends AbstractController
{
    public function index(OpenGraphManagerInterface $openGraph): Response
    {
        $openGraph
            ->setTitle('My website')
            ->setDescription('Some descriptions ...')
            ->setSiteName('My Blog')
        ;
            ...
        return $this-render('index.html.twig');
    }
}

{{ meta_tags(title: 'My website', siteName: 'My Blog') }}

use Rami\SeoBundle\Schema\SchemaInterface;
use Symfony\Component\HttpFoundation\Response;

...
    #[Route('/', name: 'app_home')]
    public function index(SchemaInterface $schema): Response
    {
        $person = $schema
            ->person()
            ->name('Abdel Ramadan')
            ->email('[email protected]')
            ->children([
                $schema->person()->name('Rami')->email('[email protected]')->givenName('Ramadan'), 
                $schema->person()->name('Rami 3')->email('[email protected]')
            ]);
        $schema->render($person);
    }

    #[Sitemap()]
    #[Route('/', name: 'app_home')]
    public function index() {
        ...
    }

    #[Sitemap()]
    #[Route('/blog', name: 'blog')]
    public function blogIndex() {
        ...
    }