PHP code example of mahdijd / seo-management

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

    

mahdijd / seo-management example snippets


use Mahdijd\SeoManagement\Traits\HasSeo;

class Post extends Model
{
    use HasSeo;

    // Optional: provide dynamic fallback values
    public function getSeoFallback(): array
    {
        return [
            'title'       => $this->title,
            'description' => $this->excerpt,
        ];
    }
}

use Mahdijd\SeoManagement\Facades\Seo;

// Resolve SEO data for a model
$seoData = Seo::forModel($post);

// Resolve SEO for a named route
$seoData = Seo::forRoute('home');

// Manually clear model SEO cache
Seo::clearModel($post);

// Manually clear route SEO cache
Seo::clearRoute('home');

// Flush all SEO cache entries
Seo::flushAll();

use Mahdijd\SeoManagement\Filament\SeoPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            SeoPlugin::make(),
        ]);
}

use Mahdijd\SeoManagement\Filament\Forms\SeoManagerGroup;

public static function form(Form $form): Form
{
    return $form->schema([
        // ... your other fields ...
        SeoManagerGroup::make(),
    ]);
}

// config/seo.php
return [
    'cache'                => true,        // Enable/disable SEO caching
    'cache_store'          => null,        // Cache store (null = default)
    'cache_ttl'            => 86400,       // Cache TTL in seconds (24h)
    'default_robots'       => 'index,follow',
    'default_twitter_card' => 'summary_large_image',
    'filament' => [
        'delete_empty_records' => false,   // Delete seo_metadata when all fields null
        'navigation_group'     => 'SEO',   // Filament sidebar group label
    ],
];
bash
# Publish config
php artisan vendor:publish --tag=seo-config

# Publish migrations
php artisan vendor:publish --tag=seo-migrations

# Run migrations
php artisan migrate