PHP code example of davidyell / seo

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

    

davidyell / seo example snippets


Plugin::load('Seo');

// src/Controller/AppController.php initialize() method
$this->loadComponent('Seo.Seo' => [
	'defaults' => [
		'title' => 'Dave is epic',
		'description' => 'This is an epic plugin for epic people',
		'keywords' => 'epic,plugin'
	]
];

// For the page title
echo $this->fetch('title');

// For outputting the meta tags inside <head>
echo $this->fetch('meta');

// ProvidersController::beforeRender()

if (isset($this->viewVars['content'])) {
    $this->components()->get('Seo')->setConfig('viewVar', 'article');
} elseif (isset($this->viewVars['provider'])) {
    $this->components()->get('Seo')->setConfig('viewVar', 'provider');
}

$this->Components->load('Seo.Seo', [
    'viewVar' => 'catalog',
    'fields' => [
        'title' => 'assigned_content.content.seo_title'
    ]
]);

// ExamplesController.php

$this->components()->get('Seo')->setConfig('fields.title', 'My new title');

$this->redirects = [
    '/examples/first-example' => [
        'target' => '/tutorials/first',
        'code' => 301
    ]
];
$queue->add(new \Seo\Error\Middleware\ErrorHandlerMiddleware($this->redirects))