1. Go to this page and download the library: Download tsawler/seotools 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/ */
tsawler / seotools example snippets
// file START ommited
'providers' => [
// other providers ommited
Tsawler\SEOTools\Providers\SEOToolsServiceProvider::class,
],
// file END ommited
// file START ommited
$app->register(Tsawler\SEOTools\Providers\SEOToolsServiceProvider::class);
// file END ommited
// file START ommited
'aliases' => [
// other Facades ommited
'SEOMeta' => Tsawler\SEOTools\Facades\SEOMeta::class,
'OpenGraph' => Tsawler\SEOTools\Facades\OpenGraph::class,
'Twitter' => Tsawler\SEOTools\Facades\TwitterCard::class,
// or
'SEO' => Tsawler\SEOTools\Facades\SEOTools::class,
],
// file END ommited
$seotools = app('seotools');
$metatags = app('seotools.metatags');
$twitter = app('seotools.twitter');
$opengraph = app('seotools.opengraph');
// The behavior is the same as the facade
// --------
echo app('seotools')->generate();
use Tsawler\SEOTools\Traits\SEOTools as SEOToolsTrait;
class CommomController extends Controller
{
use SEOToolsTrait;
/**
* @return \Illuminate\View\View
*/
public function index()
{
$this->seo()->setTitle('Home');
$this->seo()->setDescription('This is my page description');
$this->seo()->opengraph()->setUrl('http://current.url.com');
$this->seo()->opengraph()->addProperty('type', 'articles');
$this->seo()->twitter()->setSite('@LuizVinicius73');
$posts = Post::all();
return view('myindex', compact('posts'));
}
}
OpenGraph::addProperty($key, $value); // value can be string or array
OpenGraph::addImage($url); // add image url
OpenGraph::addImages($url); // add an array of url images
OpenGraph::setTitle($title); // define title
OpenGraph::setDescription($description); // define description
OpenGraph::setUrl($url); // define url
OpenGraph::setSiteName($name); //define site_name
// You can chain methods
OpenGraph::addProperty($key, $value)
->addImage($url)
->addImages($url)
->setTitle($title)
->setDescription($description)
->setUrl($url)
->setSiteName($name);
// Generate html tags
OpenGraph::generate();
Twitter::addValue($key, $value); // value can be string or array
Twitter::setType($type); // type of twitter card tag
Twitter::setTitle($type); // title of twitter card tag
Twitter::setSite($type); // site of twitter card tag
Twitter::setDescription($type); // description of twitter card tag
Twitter::setUrl($type); // url of twitter card tag
Twitter::addImage($url); // add image url
Twitter::addImages($url); // add an array of url images
// You can chain methods
Twitter::addValue($key, $value)
->setType($type)
->addImage($url)
->addImages($url)
->setTitle($title)
->setDescription($description)
->setUrl($url)
->setSite($name);
// Generate html tags
Twitter::generate();