PHPackages                             ariaml/ariaml-ssr-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ariaml/ariaml-ssr-php

ActiveLibrary[API Development](/categories/api)

ariaml/ariaml-ssr-php
=====================

AriaML Server Side Rendering Engine for PHP

03PHP

Since Mar 4Pushed 4mo agoCompare

[ Source](https://github.com/flavi1/ariaml-ssr-php)[ Packagist](https://packagist.org/packages/ariaml/ariaml-ssr-php)[ RSS](/packages/ariaml-ariaml-ssr-php/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

AriaML SSR Polyfill for PHP (aria-ssr-php)
==========================================

[](#ariaml-ssr-polyfill-for-php-aria-ssr-php)

**PHP SSR Implementation of Aria Markup Language**

This is the official PHP reference implementation for the **AriaML SSR Polyfill**. It provides the necessary orchestration to serve fluid AriaML documents while maintaining full SEO and backward compatibility with standard HTML clients.

---

1. Installation
---------------

[](#1-installation)

### Via Composer (Packagist)

[](#via-composer-packagist)

Once the package is published on Packagist, run:

```
composer require ariaml/ariaml-ssr-php
```

### Via GitHub Directly

[](#via-github-directly)

To use this library before it is published on Packagist, add the repository to your project's `composer.json`:

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/flavi1/ariaml-ssr-php"
        }
    ],
    "require": {
        "ariaml/ariaml-ssr-php": "dev-main"
    }
}
```

---

2. Conceptual Architecture
--------------------------

[](#2-conceptual-architecture)

The AriaML SSR implementation relies on three decoupled pillars:

1. **Request Factory**: Analyzes client intent (Headers) to determine if the server should render a full document or a fragment.
2. **AriaML Document**: Structures semantic data (JSON-LD) and manages the transport markup (`` vs ``).
3. **Response Factory**: Synchronizes the document state and ensures proper HTTP headers are sent.

---

3. Communication Protocol (Headers)
-----------------------------------

[](#3-communication-protocol-headers)

The server reacts specifically to the following headers:

HeaderValue / TypeRole`Accept``text/aria-ml-fragment`Highest priority: requests a native fragment rendering.`nav-cache``JSON Array`List of DOM keys already present in the client's cache.`ariaml-force-html``boolean`If true, forces `text/html` Content-Type (Web Extensions).`Vary` (Response)`Accept, nav-cache`Allow browser and CDN cache isolation.---

4. Deep Restoration Algorithm
-----------------------------

[](#4-deep-restoration-algorithm)

To save bandwidth, the server performs a **Deep Restoration** check for every cached component:

1. Retrieve the `cacheKey` of the component.
2. Check if `cacheKey` exists in the `nav-cache` header array.
3. **If present**: Send an empty shell ``.
4. **If absent**: Send the full content `...content...`.

*AriaML will detect the empty element and automatically re-inject the live DOM node stored locally in the client's NodeCache.*

---

5. Usage Example
----------------

[](#5-usage-example)

### Basic PHP implementation

[](#basic-php-implementation)

```
use AriaML\AriaMLRequestFactory;
use AriaML\AriaMLDocument;
use AriaML\AriaMLResponseFactory;

// 1. Initialize factories
$reqFactory = new AriaMLRequestFactory();
$doc = new AriaMLDocument([
    "name" => "Product Page",
    "inLanguage" => "en-US",
    "direction" => "ltr"
]);

// 2. Synchronize HTTP state
$respFactory = new AriaMLResponseFactory();
$respFactory->applyTo($reqFactory, $doc);

// 3. Render stream
echo $doc->startTag(['nav-base-url' => '/']);
?>
