RuntimeExtensionInterface - viames/pair GitHub Wiki

Pair framework: RuntimeExtensionInterface

Pair\Core\RuntimeExtensionInterface is the minimal runtime contract for Pair v4 extension packages.

The official name for this extension style is Runtime Extension.

It is separate from Installable Packages, the ZIP/manifest package installer classes Pair\Packages\InstallablePackage and Pair\Packages\InstallablePackageRecord.

Contract

namespace Pair\Core;

interface RuntimeExtensionInterface {
    /**
     * Register runtime services, adapters, routes, renderers, or configuration.
     */
    public function register(Application $app): void;
}

Manual registration

Runtime Extensions are registered explicitly from application bootstrap:

use Pair\Core\Application;

$app = Application::getInstance();
$app->registerRuntimeExtension(new StripeExtension());

There is no automatic discovery, no mandatory manifest, and no dependency injection container.

Example extension

use Pair\Core\AdapterKeys;
use Pair\Core\Application;
use Pair\Core\RuntimeExtensionInterface;

final class StripeExtension implements RuntimeExtensionInterface {

    /**
     * Register Stripe as the application payments adapter.
     */
    public function register(Application $app): void {
        $app->setAdapter(AdapterKeys::PAYMENTS, new StripeGateway());
    }

}

AI adapter example

use Pair\Core\AdapterKeys;
use Pair\Core\Application;
use Pair\Core\RuntimeExtensionInterface;
use Pair\Services\GeminiClient;

final class GeminiExtension implements RuntimeExtensionInterface {

    /**
     * Register Gemini as the application AI adapter.
     */
    public function register(Application $app): void {
        $app->setAdapter(AdapterKeys::AI, new GeminiClient());
    }

}

Runtime Extensions may register adapters, routes, UI renderers, or runtime configuration. Required behavior must live in code and configuration, not in comments or docblocks.

See also: Application, AdapterRegistry, InstallablePackage, InstallablePackageRecord, UiRenderer.