PHP x enhancely: improved maschine readability in no time.

PHP powers over 75% of the web – from custom applications to frameworks like Laravel, Symfony, and legacy systems. Whether you're running a homegrown CMS, a custom e-commerce platform, or any PHP-based website, enhancely brings AI-powered structured data to your stack.
With our enhancely PHP package, you can add intelligent JSON-LD schema to any PHP project. The integration connects in just a few lines of code and makes your content visible to search engines and AI systems – without manual markup or complex implementations.

enhancely automatically generates the right JSON-LD (schema.org) for each page—no manual markup, no brittle scripts.

Why it matters

Structured data improves search visibility and rich results. enhancely automates the hard parts so your team ships better SEO faster, with less custom code to maintain.

What you get

  • JSON-LD generated per page, automatically
  • ETag-based caching to minimize API calls
  • Ready-to-embed <script> output
  • Works with any PHP framework or custom code

How it works

  • Your PHP code sends the current page URL to the Enhancely API
  • enhancely returns ready-made JSON-LD for that URL
  • The client outputs it as <script type="application/ld+json"> in your HTML
  • Built-in ETag support prevents repeated fetches
how to integrate enhancely into php applications and websites and shops
how to integrate enhancely into php applications and websites and shops

Installation

    composer require enhancely/enhancely-php
  
Requirements: PHP >= 8.2

Quick setup

Set your API key via environment variable:
    ENHANCELY_API_KEY=your-api-key-for-your-domain
  
Or set it at runtime:
    \Enhancely\Client::setApiKey('your-api-key');
  

Basic usage

    <?php

require_once __DIR__ . '/vendor/autoload.php';

// Get JSON-LD for current page (auto-detects URL from $_SERVER)
$resp = \Enhancely\Client::jsonld();

if ($resp->ready()) {
    echo $resp; // outputs <script type="application/ld+json">...</script>
}
  
That's it. Seriously.

Caching with ETags

We strongly recommend caching the response to avoid unnecessary requests:
    <?php

// Load ETag from your cache
$prevEtag = $cache->get('enhancely_etag_' . md5($url));

// Request with ETag
$resp = \Enhancely\Client::jsonld(url: $url, etag: $prevEtag);

if ($resp->notModified()) {
    // Use cached data – nothing changed
    echo $cache->get('enhancely_data_' . md5($url));
} elseif ($resp->ready()) {
    // Update cache and output
    $cache->set('enhancely_etag_' . md5($url), $resp->etag());
    $cache->set('enhancely_data_' . md5($url), strval($resp));
    echo $resp;
}
  

Response methods

$resp->ready()$resp->ok()$resp->notModified()$resp->json()$resp->etag()$resp->hash()$resp->error()echo $resp<script>

Framework examples

Laravel

    // In a middleware or view composer
$jsonld = \Enhancely\Client::jsonld(url: request()->url());

if ($jsonld->ready()) {
    view()->share('jsonld', strval($jsonld));
}
  

Symfony

    // In a Twig extension or event listener
$jsonld = \Enhancely\Client::jsonld(url: $request->getUri());
  

WordPress (custom theme)

    // In functions.php or theme header
add_action('wp_head', function() {
    $resp = \Enhancely\Client::jsonld(url: get_permalink());
    if ($resp->ready()) {
        echo $resp;
    }
});
  

What about existing JSON-LD?

They can co-exist. Multiple JSON-LD blocks are evaluated and merged by processing crawlers like Google.

Compatibility & requirements

  • PHP: >= 8.2
  • Dependencies: Composer
  • Frameworks: Any (Laravel, Symfony, WordPress, custom, etc.)

Learn more