PHP code example of kreetancraft / laravel-seo

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

    

kreetancraft / laravel-seo example snippets


use Kreetancraft\Seo\Concerns\HasSeo;

class Article extends Model
{
    use HasSeo;

    public function seoDefaults(): array
    {
        return [
            'title' => $this->title,
            'description' => $this->excerpt,
            'path' => '/articles/'.$this->slug,
            'image' => null,
        ];
    }
}

$this->app->bind('acme.seo.models', fn () => [
    Article::class => [
        'label' => 'Article',
        'title' => 'title',
        'edit_route' => 'admin.articles.edit',
        'route_param' => true,
    ],
]);

$this->app->tag('acme.seo.models', \Kreetancraft\Seo\Support\SeoModelRegistry::TAG);

use Kreetancraft\Seo\Livewire\Concerns\InteractsWithSeoForm;

class EditArticle extends Component
{
    use InteractsWithSeoForm;
}

$this->app->tag([MyCheck::class], 'seo.checks.content');

$this->app->bind('acme.sitemap', fn () => ArticleSitemapProvider::class);
$this->app->tag('acme.sitemap', \Kreetancraft\Seo\Support\SitemapProviderRegistry::TAG);

// config/seo.php
'image_resolver' => \Kreetancraft\Media\Support\MediaImageResolver::class,
'og_picker_view' => 'media::picker-field',
bash
php artisan migrate
blade
@
bash
php artisan user-management:sync-permissions