PHP code example of mosaicora / plugin-core-php

1. Go to this page and download the library: Download mosaicora/plugin-core-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mosaicora / plugin-core-php example snippets


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

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

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

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

$jsonLd = MosaicoraOgJsonLd::build(new MosaicoraOgJsonLdOptions(
    schemaType: 'Product',
    name: 'Example product',
    offers: [
        '@type' => 'Offer',
        'price' => '49',
        'priceCurrency' => 'USD',
    ],
    mosaicoraOg: new MosaicoraOgOverride(
        templateId: '6a36446a0021410e8044',
        semanticValues: [
            'content.title' => 'Example product',
            'content.description' => 'A polished preview for every product page.',
            'product.price' => '$49',
            'product.features' => ['Fast setup', 'Consistent previews'],
        ],
    ),
));

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