Download the PHP package oi-lab/oi-laravel-metadata without Composer
On this page you can find all versions of the php package oi-lab/oi-laravel-metadata. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oi-lab/oi-laravel-metadata
More information about oi-lab/oi-laravel-metadata
Files in oi-lab/oi-laravel-metadata
Package oi-laravel-metadata
Short Description Polymorphic SEO metadata and Open Graph management for Laravel applications
License MIT
Informations about the package oi-laravel-metadata
OI Laravel Metadata
A Laravel package to attach polymorphic SEO metadata, Open Graph, and JSON-LD structured data to
any Eloquent model — with spatie/laravel-data DTOs, a fluent Schema.org builder, dedicated services,
validation rules, head-tag rendering, a @jsonLd Blade directive, and pluggable settings integration
(auto-wired to oi-lab/oi-laravel-settings).
Features
- Polymorphic Metadata, Open Graph & JSON-LD: a single
metadata,openGraph, andjsonLdrecord per model (morphOne) - Traits: opt in with
HasMetadata,HasOpenGraph,HasJsonLd, or the combinedHasMeta - DTOs: typed
MetadataData,OpenGraphData,OpenGraphImageData,JsonLdData(spatie/laravel-data) - Fluent Schema.org builder: compose any JSON-LD node with
Schema::article()->headline(...)->author(...) - Services & Facades:
MetaService/OgService/JsonLdService(Meta/Og/JsonLd) to read, write, and render - Blade directives:
@meta,@og,@jsonLd— render a passed model, a sharedSeo::for($model)subject, or the current route model automatically - Head-tag Rendering:
@meta/@og(orMeta::render($model)/Og::render($model)) emit escaped<meta>tags - JSON-LD Rendering:
@jsonLd(orJsonLd::render($model)) emits<script type="application/ld+json">blocks - Validation:
MetadataRequest/OpenGraphRequestform requests, plusIsoLanguageRule&RobotsRule - Setting Integration: seeds and resolves site-wide values through a pluggable
SettingStore(auto-wired tooi-lab/oi-laravel-settings, config-default fallback)
The Objects
A Metadata object:
| Field | Type |
|---|---|
title |
string |
description |
string |
keywords |
string[] |
author |
string |
copyright |
string |
language |
ISO code (e.g. fr, en) |
revisit_after |
string |
robots |
string |
googlebot |
string |
An Open Graph object:
| Field | Type |
|---|---|
type |
string |
title |
string |
description |
string |
url |
string |
image |
object (url, width, height) |
A JSON-LD object holds a list of Schema.org graphs, each rendered as its own
<script type="application/ld+json"> block:
| Field | Type |
|---|---|
graphs |
array of Schema.org nodes (Article, BreadcrumbList, Organization, …) |
All three are polymorphic, with at most one per parent (enforced by a unique index on the morph columns). The single JSON-LD record can still hold several graphs, so a page can expose multiple structured-data objects.
Requirements
- PHP 8.2+
- Laravel 11.0+, 12.0+, or 13.0+
spatie/laravel-data^4.0
Installation
The package auto-discovers its service provider. Publish and migrate:
This creates the metadata, open_graphs, and json_ld tables.
Local Development
Inside the monorepo, add a path repository to your main project's composer.json:
Usage
Make a Model Meta-aware
Write Values
The trait helpers $page->syncMetadata(...) and $page->syncOpenGraph(...) do the same. Writes use
updateOrCreate, so a parent never ends up with a second record.
Render <head> Tags
Use the Blade directives — @meta, @og, and @jsonLd:
Or render straight from the facades ({!! Meta::render($page) !!} / {!! Og::render($page) !!}).
Without passing $page
Set a shared SEO subject once and the directives render it with no argument — set it in a controller or a view composer:
When nothing is set explicitly, the subject is auto-resolved from the current route's model binding — so on
a Route::get('/pages/{page}', ...) route the directives just work with zero setup. An explicit argument
(@meta($other)) always wins, and auto-resolution can be turned off with the auto_resolve_subject config
flag.
Meta::render() outputs description, keywords, author, copyright, language, revisit-after,
robots, and googlebot tags, plus google-site-verification / google verification tags resolved from
settings. Og::render() outputs the og:* tags plus og:locale, og:site_name, and fb:app_id from
settings. Empty values are omitted; all values are HTML-escaped.
JSON-LD Structured Data
Attach Schema.org structured data (per the
Google structured data guidelines)
with the fluent Schema builder — any method call sets the matching schema.org property, and nested nodes are
resolved recursively:
JsonLd::update() accepts a JsonLdData object, a single Schema builder, or raw arrays. The single record
holds a list of graphs, so a page can expose several structured-data objects at once. The trait helper
$page->syncJsonLd(...) does the same.
Render one <script type="application/ld+json"> block per graph with the @jsonLd Blade directive (or
JsonLd::render()):
@jsonLd accepts a model, a JsonLdData object, a Schema builder, or a raw array — handy for ad-hoc,
non-persisted structured data:
The rendered JSON is encoded with flags that keep it safe inside a <script> tag (<, >, and & are
hex-escaped), and a top-level @context (https://schema.org by default) is injected when the graph does not
declare its own. Enable json_ld.pretty in the config to pretty-print while debugging.
Validation
The IsoLanguageRule and RobotsRule rules are reusable on their own.
Setting Integration
Seed the package defaults into your settings backend:
Settings are read and written through a pluggable SettingStore. Install the
recommended oi-lab/oi-laravel-settings
(listed under suggest) and it is wired automatically. Without it, the package
falls back to a generic key/value Setting model or no-ops gracefully.
This inserts the following keys (idempotently — existing keys are never overwritten):
| Key | Default |
|---|---|
METADATA_FACEBOOK_APP_ID |
"" |
METADATA_GOOGLE_SITE_VERIFICATION |
"" |
METADATA_GOOGLE_BOT |
"" |
METADATA_GOOGLE |
"" |
METADATA_ROBOTS |
index, follow |
METADATA_OG_LOCALE |
fr |
METADATA_OG_SITE_NAME |
"" |
METADATA_OG_TYPE |
website |
Configure the backend in config/oi-laravel-metadata.php. Leave store null to auto-detect; the
model / column keys drive the generic key/value fallback:
When no store is present, the resolver and installer no-op gracefully and fall back to config defaults. See Advanced → Setting Integration.
Overriding Models
Resolve models through OiMetadata so your overrides apply everywhere:
AI Assistant Skills
Testing
License
The MIT License (MIT). Please see the License File for more information.
Credits
Olivier Lacombe - Creator and maintainer
Olivier is a Product & Technology Director based in Montpellier, France, with over 20 years of experience innovating in UX/UI and emerging technologies. He specializes in guiding enterprises toward cutting-edge digital solutions, combining user-centered design with continuous optimization and artificial intelligence integration.
Projects & Resources:
- OI Dev Docs - Documentation for all Open Source OI Lab packages
- OnAI - Training courses and masterclasses on generative AI for businesses
- Promptr - Prompt engineering Management Platform
Support
For support, please open an issue on the GitHub repository.
All versions of oi-laravel-metadata with dependencies
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
spatie/laravel-data Version ^4.0