Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Seo Bundle Laravel Package

ayrel/seo-bundle

View on GitHub
Deep Wiki
Context7

AyrelSeoBundle

With this bundle you can configure html meta tag and title tag in a config file : /app/config/seo.yml or just by adding an seo annotation.

You can write meta tags with Twig patterns. The available variables are those in the Request attributes.

SensioLabsInsight Build Status Coverage Status

Install

###Step 1 : Download

use composer...

composer require ayrel/seo-bundle dev-master

###Step 2 : Enable The Bundle add the Bundle to your application kernel

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Ayrel\SeoBundle\AyrelSeoBundle(),
        // ...
    );
}

it's done... you can enjoy!!!

Configure Your first Route

use Ayrel\SeoBundle\Annotation\SeoAnnotation as Seo;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="homepage")
     * @Seo({
     *     "title": "my Website | {{_route}}",
     *     "description": "this is the route {{_route}} of my website"
     * })
     */
    public function indexAction(Request $request)
    {
        // replace this example code with whatever you need
        return $this->render('default/index.html.twig', [
            'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
        ]);
    }
    
    /*....*/
}

Use with The ParamConverter Component

The ParamConverter Component register the params attributes of your Controller in the Request attributes.

With this Bundle you can access these Object to write amazing templates.

use Ayrel\SeoBundle\Annotation\SeoAnnotation as Seo;

use AppBundle\Entity\Product;

class DefaultController extends Controller
{
    /**
     * @Route("/product/{id}", name="product")
     * @Seo({
     *     "title": "{{product.title}} : {{product.price}} €",
     *     "description": "{{product.desc}}"
     * })
     */
    public function productAction(Product $product)
    {
        /*.....*/
    }
    
    /*....*/
}

Configure all your routes in one file

You can set your metaTag Templates by annotation. But you can also write a yml file to configure all you routes.

Just create a app/config/seo.yml file

and configure your templates :

homepage:
    title: 'my beautifull title'
    description: 'this is a description'
    og_title: 'you can share this'
    og_description: 'this is a so interesting webpage....'

product:
    title: '{{product.title}} : {{product.price}} €'
    description: '{{product.desc}}'

Configure default meta

you can add default value to the meta.

Just write you're app/config/config.yml file

ayrel_seo:
    default:
        title: 'my webisite | {_route}'

if you want to use the default meta value, configure the route meta with a NULL value.

homepage:
    title: ~

##Resources Twig Strategy

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode