Add Mosaicora to any PHP application

Use the framework-agnostic Composer package to build Mosaicora image URLs, publish crawler-readable social metadata, and provide optional JSON-LD render values from Laravel, Symfony, WordPress, or custom PHP applications.

What this integration does

  • Turns each public page URL into a stable Mosaicora image URL.
  • Provides the URL for the Open Graph and Twitter tags your PHP template emits.
  • Supports deliberate and scheduled image URL versioning with v.
  • Builds and safely serializes optional JSON-LD render values.

Expected outcome

Your PHP application publishes one predictable Mosaicora image URL per page and can safely provide JSON-LD values when the image needs deliberate content.

How the pieces connect

The integration connects content your application already knows about to the metadata a social crawler can read.

  1. Application page data
  2. Public page URL and optional render values
  3. Mosaicora PHP helpers
  4. Server-rendered social metadata
  5. Social preview

Use this integration when

  • Your application renders HTML on the server or during a static build.
  • You can edit the document head, template, or SEO layer that emits metadata.
  • You use Laravel, Symfony, WordPress, or another PHP 8.1+ application.

Choose another path

Choose the Next.js guide when App Router metadata can handle the integration for you.

Use the native Next.js package

Before you begin

  • A PHP 8.1 or newer application that can return server-rendered or statically generated HTML.
  • Composer access from the application project root.
  • The public URL for each integrated page and your public Mosaicora site ID.
  • Access to the PHP template, document head, or SEO layer that emits meta and JSON-LD script tags.
Package
mosaicora/plugin-core-php 1.0.0
Runtime
PHP 8.1+
Framework
Laravel, Symfony, WordPress, or custom PHP
License
Apache-2.0
1

Install the PHP package

Add the framework-agnostic Composer package to your application.

Install from the application project root. The package is dependency-free, immutable, and works with Laravel, Symfony, WordPress, or a custom rendering layer.

Install with Composer

composer require mosaicora/plugin-core-php

Expected result

  • The dependency appears in composer.json and composer.lock.
  • Your application can autoload the Mosaicora\PluginCore namespace.
2

Build the image URL

Turn the public page identity into a deterministic Mosaicora CDN address.

Call OgImageUrl::build while rendering the page or preparing its static output. Pass the public site ID and the same absolute page URL your application publishes.

The helper normalizes the path, ignores fragments, filters default tracking parameters, and produces the same image URL for the same page identity.

Generate the CDN URL

use Mosaicora\PluginCore\OgImageUrl;
use Mosaicora\PluginCore\OgImageUrlOptions;

$imageUrl = OgImageUrl::build(new OgImageUrlOptions(
    siteId: "321cac22d2103fb1660c50bd",
    pageHref: "https://example.com/products/view?sku=123&page=2",
));

// https://cdn.mosaicora.io/s/321cac22d2103fb1660c50bd/products/view%3Fpage%3D2%26sku%3D123.jpg

Expected result

  • imageUrl starts with https://cdn.mosaicora.io/s/.
  • Retained page queries appear percent-encoded before .jpg.
3

Version a refreshed social image

Use v only for deliberate social-image cache rotation.

Set cacheVersion to a non-empty deployment, release, or content revision you control. It safely encodes the value, replaces a source URL's existing v, and takes precedence over a cacheBuster schedule.

For automatic rotation, use a schedule such as monthly. When neither option is supplied, the image URL has no post-.jpg cache token.

Manual image version

$imageUrl = OgImageUrl::build(new OgImageUrlOptions(
    siteId: "321cac22d2103fb1660c50bd",
    pageHref: "https://example.com/products/view?sku=123",
    cacheVersion: "release-2026-07",
));

// https://cdn.mosaicora.io/s/321cac22d2103fb1660c50bd/products/view%3Fsku%3D123.jpg?v=release-2026-07

Monthly image version

$imageUrl = OgImageUrl::build(new OgImageUrlOptions(
    siteId: "321cac22d2103fb1660c50bd",
    pageHref: "https://example.com/products/view",
    cacheBuster: "monthly",
));
4

Publish the social metadata

Use the generated URL in standard Open Graph and X/Twitter tags.

Pass $imageUrl into your Blade, Twig, WordPress, or custom PHP template. Render these tags in the document head before returning the page to crawlers.

Framework-neutral PHP template

<?php /** @var string $imageUrl */ ?>
<meta property="og:image" content="<?= htmlspecialchars($imageUrl, ENT_QUOTES, 'UTF-8') ?>" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="<?= htmlspecialchars($imageUrl, ENT_QUOTES, 'UTF-8') ?>" />
5

Supply image-render content

Build and safely serialize JSON-LD values for the Mosaicora generator.

Keep your existing Schema.org fields and add mosaicora:og semantic values for content the generator should render exactly. These overrides guide the Open Graph image without replacing normal page metadata.

MosaicoraOgJsonLd::serialize escapes less-than characters, so the result can be embedded safely as JSON-LD script text.

Build and serialize the override

use Mosaicora\PluginCore\MosaicoraOgJsonLd;
use Mosaicora\PluginCore\MosaicoraOgJsonLdOptions;

$jsonLd = MosaicoraOgJsonLd::build(new MosaicoraOgJsonLdOptions(
    schemaType: "Product",
    name: "Example product",
    additionalFields: [
        "offers" => ["@type" => "Offer", "price" => "49", "priceCurrency" => "USD"],
    ],
    mosaicoraOg: [
        "schemaVersion" => 3,
        "semanticValues" => [
            "content.title" => "Example product",
            "content.description" => "A polished product preview.",
            "product.price" => "$49",
            "product.features" => ["Fast setup", "Consistent previews"],
        ],
    ],
));

$serializedJsonLd = MosaicoraOgJsonLd::serialize($jsonLd);

Embed with your template engine

Insert serialized JSON once as the text content of an application/ld+json script.

<script type="application/ld+json"><?= $serializedJsonLd ?></script>
6

Verify the published output

Check the server-rendered HTML, image URL, and JSON-LD together.

Publish the page at its public URL, inspect the initial HTML response, and run the URL through the Open Graph Checker.

Confirm the image metadata uses $imageUrl, the page query is encoded before .jpg when relevant, and the JSON-LD contains the intended semantic render values.

Expected result

  • The initial HTML contains og:image and twitter:image.
  • The JSON-LD script parses without errors.
  • The checker recognizes the Mosaicora CDN image.

Reference

Advanced usage

Deterministic URL rules

The same public page input always maps to the same normalized image location.

  • The root path becomes https://cdn.mosaicora.io/s/{siteId}.jpg.
  • Nested paths remain below /s/{siteId}.
  • Retained page queries are sorted, then percent-encoded as one suffix before .jpg.
  • Default tracking and control parameters are omitted, while v is reserved for cache rotation.
  • Hash fragments are ignored and UTF-8 paths remain readable.
  • cacheVersion replaces an existing v and wins over cacheBuster.

PHP public contract

The package exposes focused immutable values and static helpers for PHP applications.

  • OgImageUrl and OgImageUrlOptions for CDN image URLs.
  • OgImageCacheBuster for daily, weekly, monthly, and custom duration tokens.
  • MosaicoraOgJsonLd and MosaicoraOgJsonLdOptions for v3 overrides.
  • MosaicoraOgJsonLd::serialize for safe HTML embedding.

Help

Troubleshooting

Composer cannot install the package

Confirm the project uses PHP 8.1 or newer and that Composer can access Packagist. Require the package from the application root rather than a nested vendor directory.

The social crawler does not see the tags

Render the metadata in PHP before sending the response. Tags injected only after browser JavaScript runs are not reliable for social crawlers.

A page query does not affect the image

Pass the complete page URL to pageHref. Retained query entries are sorted and encoded before .jpg; actual query values after .jpg are intentionally ignored for page lookup.

The JSON-LD script is quoted or malformed

Embed the output from MosaicoraOgJsonLd::serialize once as script text. Do not run json_encode on the serialized string a second time.

A platform keeps showing an older social preview

Verify the public page exposes the intended metadata and image, then set cacheVersion for the new asset or choose the least-frequent suitable cacheBuster schedule. A versioned image does not make a third-party platform re-crawl an already cached page preview.

Need help with another publishing workflow?

Open the dashboard to start with the current integrations, or contact us if you need a different workflow.