PHP code example of imw / laravel-meta
1. Go to this page and download the library: Download imw/laravel-meta 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/ */
imw / laravel-meta example snippets
return
[
'home' =>
[
'title|og:title|twitter:title' => 'Home page',
'description|twitter:description|og:description' => 'Home description',
'schema' =>
[
[
"@type" => "Organization",
"url" => "http://www.example.com",
"logo" => "http://www.example.com/images/logo.png"
],
[
'@type' => 'BreadcrumbList',
'itemListElement' =>
[
[
'@type' => 'ListItem',
'position' => 1,
'name' => 'Home Page',
'item' => 'http://www.example.com'
]
]
]
]
],
'App\Book' => 'App\Seo\Book'
];
namespace App\Seo;
use IMW\LaravelMeta\AbstractMetaGenerator;
class Book extends AbstractMetaGenerator
{
public function generate($book): string
{
$this->meta(
[
'title' => $book->name,
'description' => $book->description,
'schema' =>
[
[
'@type' => 'BreadcrumbList',
'itemListElement' =>
[
[
'@type' => 'ListItem',
'position' => 1,
'name' => 'Books',
'item' => 'http://www.example.com/books'
],
[
'@type' => 'ListItem',
'position' => 2,
'name' => $book->name,
'item' => 'http://www.example.com/books/1'
]
]
]
]
]);
return $this->toString();
}
}