waffle-commons / runtime
Runtime component for Waffle framework.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/waffle-commons/runtime
Requires
- php: ^8.4
- waffle-commons/container: ^0.1.0-alpha1
- waffle-commons/http: ^0.1.0-alpha1
- waffle-commons/waffle: ^0.1.0-alpha2
Requires (Dev)
- carthage-software/mago: ^1.0.0-beta.31
- php-mock/php-mock-phpunit: ^2.13
- phpunit/phpunit: ^12.0
- vimeo/psalm: ^6.13
This package is auto-updated.
Last update: 2025-11-25 12:57:21 UTC
README
Waffle Commons - Runtime Component
The Runtime component is the orchestrator of the Waffle Framework. It acts as the "glue" between the low-level components (HTTP, Container) and the framework Core (Kernel).
Its primary responsibility is to manage the request lifecycle: creating the request from global state, booting the kernel with the necessary dependencies, handling the request, and emitting the response to the client.
Features
-
Lifecycle Orchestration: Manages the full flow from Request creation to Response emission.
-
Dependency Injection Integration: Automatically instantiates and injects the PSR-11 Container implementation into the Kernel.
-
PSR-7 / PSR-17 Integration: Uses the HTTP component factories to create standard ServerRequest objects.
-
Response Emission: Uses the ResponseEmitter to send headers and body content to the output buffer.
Installation
You can install the package via Composer. Note that this package typically requires the core and other components.
composer require waffle-commons/runtime
Usage
The Runtime is designed to be used in your application's entry point (usually public/index.php).
1. Standard Usage
In your index.php file, you simply need to instantiate your Kernel and the Runtime, then call run().
<?php declare(strict_types=1); use Waffle\Commons\Runtime\WaffleRuntime; use App\Kernel; // Your application's Kernel extending Waffle\Kernel require_once __DIR__ . '/../vendor/autoload.php'; // Define the application root constant define('APP_ROOT', dirname(__DIR__)); // Instantiate the Kernel $kernel = new Kernel(); // Instantiate the Runtime $runtime = new WaffleRuntime(); // Run the application // This will: // 1. Initialize the DI Container // 2. Create a PSR-7 Request from globals // 3. Boot and Configure the Kernel // 4. Dispatch the Request to the Router/Controller // 5. Emit the final Response to the browser $runtime->run($kernel);
Architecture
The Runtime component decouples the Core from specific implementations of "infrastructure" concerns.
-
Input: It uses
Waffle\Commons\Http\Factory\GlobalsFactoryto create a ServerRequestInterface. -
Processing: It delegates the business logic to
KernelInterface::handle($request). -
Dependencies: It provides
Waffle\Commons\Container\Containeras the PSR-11 implementation for the Kernel. -
Output: It uses
Waffle\Commons\Http\Emitter\ResponseEmitterto send the ResponseInterface.
This design allows the Core Kernel to remain agnostic of how requests are created or sent, making it easier to test or run in different contexts (like CLI or long-running processes).
Testing
This component is tested via integration tests within the Waffle Workspace.
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.