Runtime component for Waffle framework.

Installs: 1

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/waffle-commons/runtime

0.1.0-alpha4 2026-01-05 10:42 UTC

This package is auto-updated.

Last update: 2026-01-06 15:23:31 UTC


README

PHP Version Require PHP CI codecov Latest Stable Version Latest Unstable Version Total Downloads Packagist License

Waffle Runtime Component

The Waffle Runtime is the agnostic orchestration layer of the Waffle framework. It is responsible for gluing the Kernel, Request, and Response Emitter together to execute the application lifecycle.

📦 Installation

composer require waffle-commons/runtime

🚀 Usage

The Runtime is typically used in your application's entry point (public/index.php).

It requires a fully configured KernelInterface, a ServerRequestInterface, and a ResponseEmitterInterface.

Example (public/index.php)

<?php

declare(strict_types=1);

use Waffle\Commons\Config\Config;
use Waffle\Commons\Container\Container;
use Waffle\Commons\Http\Emitter\ResponseEmitter;
use Waffle\Commons\Http\Factory\GlobalsFactory;
use Waffle\Commons\Runtime\WaffleRuntime;
use Waffle\Commons\Security\Security;
use App\Kernel; // Your application Kernel

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

define('APP_ROOT', dirname(__DIR__));

// 1. Setup Infrastructure Dependencies
// ------------------------------------
// Create the Config (pointing to your config directory)
$config = new Config(
    configDir: APP_ROOT . '/config',
    environment: getenv('APP_ENV') ?: 'prod'
);

// Create the Security implementation
$security = new Security($config);

// Create the DI Container
$container = new Container();

// 2. Setup the Kernel
// -------------------
$kernel = new Kernel();

// Inject dependencies into the Kernel
// (The Kernel needs these to boot and configure the system)
$kernel->setConfiguration($config);
$kernel->setSecurity($security);
$kernel->setContainerImplementation($container);

// 3. Create Request & Emitter
// ---------------------------
$requestFactory = new GlobalsFactory();
$request = $requestFactory->createServerRequestFromGlobals();

$emitter = new ResponseEmitter();

// 4. Instantiate the Runtime
// --------------------------
$runtime = new WaffleRuntime();

// 5. Run the Application
// ----------------------
// The Runtime orchestrates the flow:
// Request -> Kernel -> Response -> Emitter
$runtime->run($kernel, $request, $emitter);

Features

  • Agnostic Execution: The Runtime doesn't know about your controllers or business logic. It only deals with PSR interfaces.
  • Decoupled Architecture: Forces a clean separation between the Application (Kernel), the Input (Request), and the Output (Emitter).
  • PSR-7 & PSR-15 Compliant: Built on top of standard HTTP message interfaces.

Testing

To run the tests, use the following command:

composer tests

Contributing

Contributions are welcome! Please refer to CONTRIBUTING.md for details.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.