PHP code example of serfix / content-ai-laravel

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

    

serfix / content-ai-laravel example snippets


use Serfix\ContentAi\Models\Article;

$articles = Article::published()->latest('published_at')->paginate();

serfix_head();  serfix_body();  serfix_body_below();  serfix_article();

use Serfix\ContentAi\Rendering\Renderer;

public function show(string $slug)
{
    $article = \Serfix\ContentAi\Models\Article::where('slug', $slug)->firstOrFail();

    app(Renderer::class)->use($article);

    return view('my-own-blog-page');   // your view, your design
}

app(\Serfix\ContentAi\Services\MetaBuilder::class)->for($article);
app(\Serfix\ContentAi\Services\SchemaBuilder::class)->for($article);   // array

app(\Serfix\ContentAi\Http\Controllers\ArticleController::class)->previewUrl($article);

use Serfix\ContentAi\Events\{ArticleReceived, ArticlePublished, ArticleUpdated};
bash
php artisan content-ai:verify
bash
php artisan vendor:publish --tag=content-ai-config
php artisan vendor:publish --tag=content-ai-views       # unstyled on purpose
php artisan vendor:publish --tag=content-ai-migrations
jsonc
{
  "event": "article.published",     // or article.updated / article.unpublished / verify
  "external_id": null,              // the id WE returned previously; null on first publish
  "article": {
    "h1": "…", "slug": "…", "html": "…", "markdown": "…",
    "meta_title": "…", "meta_description": "…",
    "word_count": 1200, "language": "en",
    "target_keyword": "…", "secondary_keywords": ["…"]
  },
  "sent_at": "2026-07-21T06:00:00+00:00"
}