thgs / amphp-bootstrap
一个引导 Amphp HTTP 服务器启动过程的包
v0.5.0
2024-09-06 07:44 UTC
Requires
- php: >=8.2
- ext-pcntl: ^8.2
- amphp/http-server: ^3
- amphp/http-server-router: ^2
- amphp/http-server-session: ^3.0
- amphp/http-server-static-content: ^2
- amphp/log: ^2
- amphp/websocket-server: ^4.0
Requires (Dev)
- amphp/php-cs-fixer-config: ^2.0.1
- amphp/phpunit-util: ^3.0
- illuminate/container: ^11.22
- phpunit/phpunit: ^9
- psalm/phar: ^5.19
- rdlowrey/auryn: ^1.4
README
注意,此包处于 实验性/探索性 阶段。
这是一个便利包,用于启动 Amphp HTTP 服务器。它导出配置对象,这些对象用作输入和配置加载器,用于几种基本格式。它需要一个容器实现来适配接口,然而一些基本的适配器已经为一些容器包提供。
功能
- 通过容器集成,您可以设置路由并使用 DI。
用法
您可以像这样启动它,以下示例使用 Auryn Injector。
use Auryn\Injector; use thgs\Bootstrap\Bootstrap; use thgs\Bootstrap\Config\Loader\PhpFileLoader; use thgs\Bootstrap\DependencyInjection\AurynInjector; require \dirname(__DIR__) . '/vendor/autoload.php'; // Loader for config.php which contains the main configuration $loader = new PhpFileLoader(getcwd() . '/' . ($argv[1] ?? 'config.php')); // Pick an injector $injector = new AurynInjector(new Injector()); // Finally, boot everything new Bootstrap($loader->load(), $injector);
请参阅 examples/
目录中的示例配置。所有配置对象都包含您可以使用 Amphp 直接作为构造函数参数设置的各种选项。
此包开箱即支持以下注入器/容器