quadcompanies / metadata
A unified Metadata, SEO, and Social Media library for Laravel.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/quadcompanies/metadata
Requires
- php: ^8.1
- illuminate/contracts: ^10.0|^11.0
- illuminate/database: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
This package is auto-updated.
Last update: 2026-01-28 17:35:44 UTC
README
A unified Metadata, SEO, and Social Media library for Laravel. Define your page information once and render it everywhere: HTML Meta tags, Open Graph, Twitter Cards, and Schema.org JSON-LD.
Features
- Fluent API: Easily set metadata in your controllers.
- Eloquent Integration: Use the
HasMetadatatrait to map model attributes to SEO fields automatically. - Blade Directive: Simple
@metadatadirective to render everything in your<head>. - Schema.org: Helpers for generating standard JSON-LD scripts.
- Sitemaps: Generate
sitemap.xmlvia Artisan command.
Installation
composer require quadcompanies/metadata
Usage
1. Define Once (Controller)
use QuadCompanies\Metadata\Facades\Metadata; public function show(Product $product) { Metadata::title($product->name) ->description($product->excerpt) ->image($product->featured_image_url) ->url(url()->current()) ->siteName('My Awesome Store') ->twitterCard('summary_large_image'); return view('products.show', compact('product')); }
2. Render Everywhere (Blade)
Add the directive to your layout's <head>:
<!DOCTYPE html> <html> <head> @metadata </head> ...
3. Eloquent Integration
Add the HasMetadata trait to your models:
use QuadCompanies\Metadata\Traits\HasMetadata; class Post extends Model { use HasMetadata; public function metadataMapping(): array { return [ 'title' => 'title', 'description' => 'excerpt', 'image' => fn($model) => $model->getFirstMediaUrl('images'), ]; } }
Then in your controller:
public function show(Post $post) { $post->applyMetadata(); return view('posts.show'); }
4. Schema.org JSON-LD
use QuadCompanies\Metadata\Schema\SchemaBuilder; Metadata::addSchema(SchemaBuilder::article([ 'headline' => 'Awesome Article', 'author' => ['@type' => 'Person', 'name' => 'John Doe'], ]));
5. Sitemaps
To generate a sitemap:
php artisan metadata:sitemap
Standards
This package follows PSR-12 coding standards and is designed to be data-agnostic (no migrations required).
License
The MIT License (MIT). Please see License File for more information.