2017 © Pedro Peláez
 

library seo_bundle

image

rudak/seo_bundle

  • Friday, April 7, 2017
  • by rudak
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

seo_bundle

Manage your meta tags easily, (*1)

Installation

composer require rudak/seo_bundle

Enable the Bundle

#AppKernel.php
$bundles = [
            //...
            new Rudak\SeoBundle\RudakSeoBundle(),
        ];

Configuration

Some parameters are required and some optional, (*2)

#config.yml
rudak_seo:
    title: title you want
    description: Description you want
    author: RudaK
    og_title: My Website - Blog                          #optional
    og_description: My website is blue                   #optional
    og_image: relative/path/article.jpg                  #optional
    og_type: article                                     #optional
    og_locale: fr_FR                                     #optional
    fb_app_id: abcdefghijklmnopqrstuvwxyz0123456789      #optional

Usage

The Meta Object is auto configured with de default values from config.yml. You just have to call twig functions in your view for print the hydrated meta tag., (*3)

Basic example:

<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    {{ seo_title() }}
    {{ seo_description() }}    
    {{ seo_author() }}
</head>

Will become, (*4)

<html lang="fr">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>your default title</title>
    <meta name="description" content="your default description">    
    <meta name="author" content="your default author">
</head>

Update the values in your controller

public function blogAction($id)
    {
        $em      = $this->getDoctrine()->getManager();
        $article = $em->getRepository('AppBundle:Blog')->find($id);

        $metaValues  = [
            'title'       => $article->getName(),
            'description' => 'what an article ! it\'s so good',
            'author'      => $article->getAuthor(),
            'og_type'     => 'article',
        ];
        $metaBuilder = $this->get('rudak_seo.builder');
        $metaBuilder->updateMetaObject($metaValues);

        return $this->render('default/article.html.twig', [
            'article' => $article,
        ]);
    }

The values will be updated in your template. That's all ;), (*5)

The Versions

07/04 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires