spatie/laravel-url-ai-transformer
Laravel package to transform URLs and their web content with AI. Extract structured data (JSON-LD), generate summaries, images, or custom outputs via transformers and prompts. Runs via an Artisan command and stores results in the database for later retrieval.
This section covers the fundamental features of the Laravel URL AI Transformer package.
The package ships with two powerful transformers out of the box:
Extracts structured data from web pages in LD+JSON format. This transformer analyzes the content and generates comprehensive structured data following Schema.org standards.
use Spatie\LaravelUrlAiTransformer\Transformers\LdJsonTransformer;
Transform::urls('https://example.com/article')
->usingTransformers(new LdJsonTransformer);
Perfect for:
Generates images based on web content using AI image generation models. This transformer reads the content and creates visual representations.
use Spatie\LaravelUrlAiTransformer\Transformers\ImageTransformer;
Transform::urls('https://example.com/blog-post')
->usingTransformers(new ImageTransformer);
Perfect for:
Transform::urls(
'https://example.com/page1',
'https://example.com/page2',
'https://example.com/page3'
)->usingTransformers(new LdJsonTransformer);
Transform::urls('https://example.com/article')
->usingTransformers(
new LdJsonTransformer,
new ImageTransformer,
new CustomSummaryTransformer
);
Transform::urls(
fn() => Article::published()->pluck('url')->toArray()
)->usingTransformers(new LdJsonTransformer);
How can I help you explore Laravel packages today?