laravel-seo maintained by triomize
Triomize for Laravel
SEO, AEO (answer-engine) and GEO (generative-engine) scoring for any Eloquent model or any live URL: 47 checks, JSON-LD schema, llms.txt, robots.txt rules for AI crawlers and IndexNow. A port of the Triomize WordPress plugin with no WordPress code in it.
- Score anything.
$post->analyzeSeo()for models,php artisan triomize:audit https://…for any website (Shopify, WordPress, a React SSR app: if it returns HTML, it can be scored). - Three matrices, 100 points each. SEO (22 checks), AEO (11 + optional intent check), GEO (11 + informational
llms.txtrow), with the same weights, caps and messages as the plugin. - Framework-free engine. The analyzers take a plain
AnalysisContextobject and never touch the database, the HTTP layer or the container, so you can useTriomize\LaravelSeo\Enginein any PHP project. - No Tailwind clashes. The score panel ships ~2 KB of vanilla CSS (every selector is
.tmz-*) and ~1 KB of vanilla JS.
Requires PHP 8.2+ and Laravel 10, 11 or 12.
Installation
composer require triomize/laravel-seo
The service provider and the Triomize facade are auto-discovered.
Publish the config and the migration, then migrate:
php artisan vendor:publish --tag=triomize-config
php artisan vendor:publish --tag=triomize-migrations
php artisan migrate
Prefer no publish step for the migration? Set 'database' => ['auto_migrate' => true] in config/triomize.php and run php artisan migrate.
Other publish tags: triomize-views (override the Blade view), triomize-assets (CSS/JS as static files).
Quick start
1. Add the trait to a model
use Illuminate\Database\Eloquent\Model;
use Triomize\LaravelSeo\Traits\HasTriomize;
class Post extends Model
{
use HasTriomize;
// Optional: the public URL of this record.
public function triomizeUrl(): string
{
return route('posts.show', $this);
}
}
The trait finds common column names on its own (title, content or body, excerpt, slug, published_at, an author relation …). To map your own, see Field mapping.
2. Analyze and read the scores
$post->setTriomize([
'focus_keyword' => 'generative engine optimization',
'supporting_keywords' => ['GEO', 'AI search'],
]);
$report = $post->analyzeSeo(); // runs SEO + AEO + GEO and stores the result
$report->seo->score; // 92
$report->aeo->grade(); // 'good' | 'average' | 'poor'
$report->geo->failing(); // checks that lost points, biggest loss first
$report->average(); // 89
$post->triomizeScore('geo'); // stored score, no recalculation
$post->triomizeScore('average');
$post->triomizeChecks('seo'); // stored check rows
Post::triomizeScoreAtLeast(75, 'seo')->get(); // query scope
Pass overrides for one run: $post->analyzeSeo(['robotsTxt' => $txt]). Don't store: $post->analyzeSeo(persist: false).
Re-score on save if you want it automatic:
protected static function booted(): void
{
static::saved(fn (Post $post) => $post->analyzeSeo());
}
3. Show the score panel
<x-triomize::score-panel :model="$post" />
| Prop | Default | |
|---|---|---|
model |
required | Model using HasTriomize |
:matrices |
config | e.g. ['seo', 'geo'] |
:analyze |
false |
Analyze on the fly if nothing is stored yet |
:details |
true |
Show the per-check list |
:failing-only |
false |
Only list checks that lost points |
An optional Re-analyze button posts to a package route. Enable it in config/triomize.php:
'ui' => ['reanalyze' => [
'enabled' => true,
'middleware' => ['web', 'auth'],
'authorize' => 'update', // REQUIRED Gate ability (receives the model); without it the route returns 403
'models' => ['post' => App\Models\Post::class], // only these classes can be analyzed
]],
The component inlines its CSS and JS once per page. Set ui.csp_nonce if you use a Content-Security-Policy.
4. Schema.org JSON-LD
<head>
@triomizeSchema($post)
</head>
Emits one @graph with Organization (when site.brand_name is set), BlogPosting/Article/NewsArticle, Person (author), FAQPage (from ? headings or explicit pairs) and optional Speakable. Switch parts off in schema.
Auditing a live URL
php artisan triomize:audit https://example.com/blog/post --keyword="generative engine optimization"
php artisan triomize:audit https://example.com --matrix=geo --failing
php artisan triomize:audit https://example.com --json > report.json
php artisan triomize:audit https://example.com --min-score=70 # exit code 1 below 70, handy in CI
From code (an SSRF guard refuses private and loopback addresses unless you pass trusted: true):
use Triomize\LaravelSeo\Facades\Triomize;
$report = Triomize::audit('https://example.com', focusKeyword: 'geo');
The auditor fetches the page, robots.txt, llms.txt and the sitemap, reads title, meta, canonical, robots meta, JSON-LD and the main content. It does not run JavaScript, so a purely client-rendered page is scored on its server-rendered HTML.
Other commands:
| Command | |
|---|---|
triomize:analyze "App\Models\Post" [--id=1] |
Score every record (chunked) |
triomize:indexnow {urls*} [--sitemap=URL] [--generate-key] |
Submit URLs / create a key |
triomize:llms [--write] |
Print or write public/llms.txt |
llms.txt, robots.txt, IndexNow
Routes are registered automatically (disable all with routes.enabled = false).
/llms.txt: generated from the models you list, cached (llms.cache_ttl) and flushed when a HasTriomize model is saved or deleted:
'llms' => [
'enabled' => true,
'sections' => [
['title' => 'Articles', 'model' => App\Models\Post::class, 'scope' => 'published', 'limit' => 50],
],
'static' => ['Docs' => [['title' => 'Getting started', 'url' => 'https://example.com/docs']]],
'rules' => ['max_summary_words' => 30, 'include_dates' => true, 'include_authors' => true, 'exclude_noindex' => true],
],
robots.txt: scoring reads public/robots.txt by default (no network). Set robots.source to url to fetch it over HTTP (cached for 15 minutes) or inline. To have Triomize serve a robots.txt that welcomes AI crawlers, set robots.serve = true and remove public/robots.txt.
IndexNow:
php artisan triomize:indexnow --generate-key # prints a key
TRIOMIZE_INDEXNOW_ENABLED=true
TRIOMIZE_INDEXNOW_KEY=…
/{key}.txt is served for verification. Set indexnow.auto_submit = true to ping IndexNow (queued) whenever a model is saved, or call Triomize::indexNow()->submit([...]).
Configuration
Everything is in config/triomize.php: site identity, enabled matrices and disabled checks, grade thresholds, field mapping, schema, llms, robots, IndexNow, HTTP, storage and routes.
Disable single checks and the matrix is rescaled over the remaining ones:
'checks' => ['matrices' => ['seo', 'geo'], 'disabled' => ['seo_toc']],
Field mapping
'models' => [
App\Models\Article::class => [
'content' => 'body_html',
'content_format' => 'markdown', // rendered with Str::markdown()
'title' => 'headline',
'meta_description' => 'seo_description',
'image' => 'cover_url',
'author' => 'writer', // relation name, or null
'author_map' => ['bio' => 'about', 'url' => 'website'],
],
],
For full control define triomizeAttributes(): array on the model and return any AnalysisContext properties.
Using the engine without Laravel
use Triomize\LaravelSeo\Engine;
use Triomize\LaravelSeo\Support\AnalysisContext;
$report = (new Engine())->analyze(AnalysisContext::make([
'html' => $html,
'title' => 'My post',
'url' => 'https://example.com/my-post',
'focusKeyword' => 'my keyword',
]));
Fields you don't know (hasViewport, sitemapAvailable, robotsTxt …) can stay null; those checks then award partial credit instead of failing. Add your own matrix with $engine->extend(new MyAnalyzer()) (implement Contracts\Analyzer).
Differences from the WordPress plugin
- Environment facts the plugin read from WordPress (theme viewport, sitemap, SEO plugins, author box) are now explicit inputs, or auto-detected when auditing a URL.
- The robots.txt loopback request is gone: it is read from a file by default, or fetched and cached.
- Data lives in one polymorphic table instead of
wp_postmeta. - Markdown content is supported through
content_format.
Deployment notes
- Cached routes: if you use
php artisan route:cache, runphp artisan route:clear(oroptimize:clear) and re-cache after changing anyroutes.*,llms.*,robots.serve, IndexNow orui.reanalyze.*setting, because the routes are only registered when those settings are on. - Physical files win: if
public/robots.txt,public/llms.txtorpublic/{key}.txtexists, the web server serves the file and never reaches Laravel. Delete the file if you want Triomize to serve it. - Catch-all routes: package routes are registered before your app's routes, so
/llms.txtnormally wins overRoute::get('/{slug}'). Confirm withphp artisan route:list --path=llms. llms.txtcontent: with nollms.sectionsit lists only your site title and description. When you add a model section, set ascope(for examplepublished) so drafts never appear in a public file.- Never pass user-supplied URLs to
Triomize::audit()withoutui-level authentication. It blocks private and reserved IPv4/IPv6 ranges, re-checks every redirect and pins the validated IP, but a public fetch endpoint should still be authenticated and rate-limited.
Testing
composer install
vendor/bin/phpunit
License
GPL-2.0-or-later, the same licence as the WordPress plugin this is derived from. See LICENSE.