waffle-commons/runtime
最新稳定版本:0.1.0-alpha4
Composer 安装命令:
composer require waffle-commons/runtime
包简介
Runtime component for Waffle framework.
README 文档
README
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.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-30