PHP code example of kfoobar / laravel-seo-tools

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

    

kfoobar / laravel-seo-tools example snippets


use KFoobar\LaravelSeoTools\Facades\Breadcrumbs;

Breadcrumbs::add('Home', route('home'))
    ->add('Blog', route('posts.index'))
    ->add($post->title);

'robots' => [
    'enabled' => true,
    'user_agents' => [
        '*' => [
            'allow' => ['/'],
            'disallow' => ['/admin', '/horizon', '/telescope'],
        ],
    ],
    'sitemap' => true, // Sitemap: {app.url}/sitemap.xml
],

'sitemap' => [
    'enabled' => true,
    'route' => '/sitemap.xml',
    'cache' => 3600, // seconds; false to disable. The cache key st::class,
    ],
],

use KFoobar\LaravelSeoTools\Contracts\Sitemapable;

class Post extends Model implements Sitemapable
{
    public function toSitemapTag(): string|array
    {
        return [
            'loc' => route('posts.show', $this),
            'lastmod' => $this->updated_at,
        ];
    }
}
bash
php artisan vendor:publish --tag=seo-config
bash
php artisan vendor:publish --tag=seo-views