Download the PHP package mosaicora/plugin-core-php without Composer
On this page you can find all versions of the php package mosaicora/plugin-core-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mosaicora/plugin-core-php
More information about mosaicora/plugin-core-php
Files in mosaicora/plugin-core-php
Package plugin-core-php
Short Description Framework-agnostic Mosaicora Open Graph image URL and JSON-LD helpers for PHP.
License Apache-2.0
Homepage https://mosaicora.io/integrations/php
Informations about the package plugin-core-php
mosaicora/plugin-core-php
Framework-agnostic PHP helpers for Mosaicora Open Graph image URLs and
mosaicora:og JSON-LD v3 overrides.
Install
The package requires PHP 8.1 or newer and has no runtime dependencies.
Build an Open Graph image URL
The output is deterministic: it normalizes duplicate and trailing path slashes,
keeps readable UTF-8 paths, ignores fragments, filters default tracking/control
parameters, and percent-encodes the sorted remaining page query into the CDN
path before .jpg. The CDN ignores query parameters after .jpg for source
page lookup.
The home page produces https://cdn.mosaicora.io/s/{siteId}.jpg nested paths
remain below /s/{siteId}. Pass baseOrigin to use a different CDN origin.
Refreshing social image URLs
Social networks can retain a link preview after their first crawl. A new image URL helps them retrieve a new asset when they re-scrape page metadata, but it does not force them to re-scrape.
Use an explicit release or content revision when one is available:
Or opt in to a UTC schedule with cacheBuster: daily, weekly, monthly,
or a positive duration such as 15m, 6h, or 7d. cacheVersion takes
precedence over cacheBuster and replaces any existing v parameter. Keep the
default stable URL unless your content genuinely needs rotation. monthly is a
good production default for most pages. The reserved v token remains after
.jpg and is cache-only.
Add a v3 JSON-LD override
Keep existing Schema.org data and add only values Mosaicora should use exactly:
serialize() removes null values recursively and escapes <, making the result
safe to embed in an HTML JSON-LD script element. The helper deliberately does
not reject semantic role names or values at runtime, applications should use
the documented v3 contract below.
Public API
OgImageUrl::build(OgImageUrlOptions $options): stringOgImageCacheBuster::build(string $schedule, ?DateTimeInterface $now = null): stringMosaicoraOgJsonLd::build(MosaicoraOgJsonLdOptions $options): arrayMosaicoraOgJsonLd::serialize(array $value): stringMosaicoraOgSemanticRoles::definitions(): arrayMosaicoraOgSemanticRoles::typeFor(string $role): ?stringMosaicoraOgSemanticRoles::acceptsValue(string $role, mixed $value): bool- Immutable value objects:
OgImageUrlOptions,MosaicoraOgJsonLdOptions,MosaicoraOgOverride, andMosaicoraOgMetric.
See Mosaicora OG Overrides v3 for the semantic-role contract.
Development and releases
Pull requests and pushes run this validation on PHP 8.1 through 8.4. To release,
create and push a semantic v{version} Git tag. The release workflow validates
the package and creates a GitHub Release. Packagist resolves the installable
version from that Git tag; register the repository there and enable its GitHub
webhook so tags are synchronized automatically. Do not add a version field to
composer.json for this VCS-distributed package.
Security
Please read SECURITY.md before reporting a vulnerability.
Licensed under the Apache License 2.0.