PHP code example of muzorix / ai-blog-engine

1. Go to this page and download the library: Download muzorix/ai-blog-engine 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/ */

    

muzorix / ai-blog-engine example snippets


use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;

class User extends Authenticatable implements FilamentUser
{
    public function canAccessPanel(Panel $panel): bool
    {
        return true; // restrict as needed
    }
}

'schedule' => [
    'fetch_topics'     => '0 */6 * * *',  // every 6 hours
    'freshness_scan'   => '0 3 * * 1',    // Mondays 3 AM
    'content_calendar' => '0 4 * * 0',    // Sundays 4 AM
    'analytics_pull'   => '0 5 * * *',    // daily 5 AM
],

use Muzorix\AiBlogEngine\AiText\AiTextManager;

$ai = app(AiTextManager::class);
$response = $ai->prompt('generate', 'Write a headline about Laravel 13');
$json = $ai->json('seo', 'Return JSON with meta_title and meta_description for...');

// routes/web.php
use Muzorix\AiBlogEngine\Models\Article;

Route::get('/blog', fn () => view('blog.index', [
    'articles' => Article::published()
        ->with(['faqs', 'images'])
        ->latest('published_at')
        ->paginate(12),
]));

Route::get('/blog/{slug}', function (string $slug) {
    $article = Article::published()
        ->where('slug', $slug)
        ->with(['faqs', 'images', 'outboundLinks.linkedArticle'])
        ->firstOrFail();

    return view('blog.show', compact('article'));
});

use Livewire\Component;
use Livewire\WithPagination;
use Muzorix\AiBlogEngine\Models\Article;

class BlogIndex extends Component
{
    use WithPagination;

    public function render()
    {
        return view('livewire.blog-index', [
            'articles' => Article::published()
                ->latest('published_at')
                ->paginate(12),
        ]);
    }
}

use Muzorix\AiBlogEngine\Pipeline\InternalLinker;

$related = app(InternalLinker::class)->findSimilarArticles($article);

Article::published()->latest('published_at')->get();
Article::pendingReview()->get();
Article::needsUpdate()->get();
Topic::readyForGeneration()->get();
Topic::scheduled()->get();

$article->publish(); // sets status, published_at, last_updated_at

use Muzorix\AiBlogEngine\Facades\AiBlogEngine;
use Muzorix\AiBlogEngine\Models\Topic;

$topic = Topic::find(1);
$article = AiBlogEngine::run($topic);

use Muzorix\AiBlogEngine\Pipeline\ArticleGenerator;

$article = ArticleGenerator::make()
    ->provider('groq')
    ->targetLength(1500)
    ->tone('professional')
    ->readingLevel('grade_8')
    ->generate($topic);

use Muzorix\AiBlogEngine\Jobs\GenerateArticleJob;

GenerateArticleJob::dispatch($topic);
bash
php artisan ai-blog-engine:install --migrate
bash
php artisan filament:assets
bash
php artisan make:filament-user --panel=ai-blog-engine
bash
php artisan queue:work
bash
php artisan vendor:publish --tag=ai-blog-engine-config --force
bash
php artisan ai-blog-engine:freshness-scan
blade
{{-- resources/views/blog/show.blade.php --}}
<head>
    <title>{{ $article->meta_title ?? $article->title }}</title>
    @if ($article->meta_description)
        <meta name="description" content="{{ $article->meta_description }}">
    @endif
    @if ($article->schema_markup)
        <script type="application/ld+json">{!! $article->schema_json !!}</script>
    @endif
</head>

<h1>{{ $article->title }}</h1>
{!! $article->body !!}

@foreach ($article->faqs as $faq)
    <details>
        <summary>{{ $faq->question }}</summary>
        <p>{{ $faq->answer }}</p>
    </details>
@endforeach
bash
php artisan filament:assets
bash
php artisan queue:work
bash
php artisan config:clear
bash
php artisan storage:link