oasis/http — 基于 Symfony MicroKernel 的 HTTP 框架,提供路由、安全、CORS、模板、中间件等 Web 应用基础能力。
| 层 | 技术 |
|---|---|
| 语言 | PHP ≥ 8.5 |
| 框架 | Symfony MicroKernel(Symfony 8.x 组件) |
| 模板 | Twig 3.x |
| HTTP | Symfony HttpFoundation 8.x |
| 路由 | Symfony Routing 8.x(YAML 配置 + 缓存 + 编程式注入) |
| 安全 | Symfony Security 8.x |
| HTTP 客户端 | Guzzle 7.x |
| 测试 | PHPUnit 13.x |
| 静态分析 | PHPStan(level 8) |
| PBT | Eris 1.x |
| 内部依赖 | oasis/utils ^3.2、oasis/logging ^3.0 |
| 包管理 | Composer |
- 源码:
Oasis\Mlib\Http\→src/ - 测试:
Oasis\Mlib\Http\Test\→tests/
src/MicroKernel.php— 核心类,继承 SymfonyHttpKernel,通过 bootstrap config 数组初始化src/Kernel/— MicroKernel 内部 trait 拆分(BootstrapTrait / RoutingTrait / MiddlewareTrait / ErrorHandlerTrait / ConvenienceTrait / ServicesTrait / CloudfrontTrustedProxyResolver)
# 安装依赖
composer install
# 运行全量测试(默认排除 PBT,适合日常验证)
./vendor/bin/phpunit
# 运行指定 suite
./vendor/bin/phpunit --testsuite cors
./vendor/bin/phpunit --testsuite security
./vendor/bin/phpunit --testsuite twig
./vendor/bin/phpunit --testsuite aws
./vendor/bin/phpunit --testsuite exceptions
# 运行 PBT 测试(需单独声明,或看 coverage 时跑)
./vendor/bin/phpunit --testsuite pbt
# 生成 coverage 报告(使用 pcov 驱动,比 Xdebug 快数倍)
php -d pcov.enabled=1 -d pcov.directory=src ./vendor/bin/phpunit --coverage-text
php -d pcov.enabled=1 -d pcov.directory=src ./vendor/bin/phpunit --coverage-html build/coverage-html
# 同时输出 junit 耗时报告 + coverage text
php -d pcov.enabled=1 -d pcov.directory=src ./vendor/bin/phpunit --log-junit build/junit-report.xml --coverage-text=build/coverage-report.txt
# 静态分析
./vendor/bin/phpstan analyse
# 对重复失败的 suite,用 --log-junit 输出日志以缩小定位
./vendor/bin/phpunit --testsuite <suite> --log-junit build/junit-<suite>.xml| Suite | 内容 |
|---|---|
| exceptions | UniquenessViolationHttpExceptionTest, HttpExceptionTest |
| cors | CrossOriginResourceSharingTest, CrossOriginResourceSharingAdvancedTest |
| security | SecurityServiceProviderTest, SecurityServiceProviderConfigurationTest, NullEntryPointTest, AccessRuleListenerTest, AbstractSimplePreAuthenticationPolicyTest |
| twig | TwigServiceProviderTest, TwigServiceProviderConfigurationTest |
| aws | ElbTrustedProxyTest |
| error-handlers | WrappedExceptionInfoTest, ExceptionWrapperTest, JsonErrorHandlerTest |
| configuration | HttpConfigurationTest, SecurityConfigurationTest, CrossOriginResourceSharingConfigurationTest, TwigConfigurationTest, CacheableRouterConfigurationTest, SimpleAccessRuleConfigurationTest, SimpleFirewallConfigurationTest, ConfigurationValidationTraitTest |
| views | AbstractSmartViewHandlerTest, JsonViewHandlerTest, DefaultHtmlRendererTest, JsonApiRendererTest, PrefilightResponseTest, RouteBasedResponseRendererResolverTest |
| routing | GroupUrlMatcherTest, GroupUrlGeneratorTest, CacheableRouterUrlMatcherWrapperTest, InheritableRouteCollectionTest, InheritableYamlFileLoaderTest, CacheableRouterTest, CacheableRouterProviderTest, FrozenRouteCollectionTest, MicroKernelRouteInjectionTest, MicroKernelRoutePreservationTest, MicroKernelRouteInjectionIntegrationTest, RouteCacheIsolationTest |
| cookie | ResponseCookieContainerTest, SimpleCookieProviderTest |
| middlewares | AbstractMiddlewareTest |
| misc | ExtendedArgumentValueResolverTest, ExtendedExceptionListnerWrapperTest, ChainedParameterBagDataProviderTest |
| integration | BootstrapConfigurationIntegrationTest, SecurityAuthenticationFlowIntegrationTest, SilexKernelCrossCommunityIntegrationTest |
| SilexKernelTest | SilexKernelTest |
| SilexKernelWebTest | SilexKernelWebTest |
| FallbackViewHandlerTest | FallbackViewHandlerTest |
| pbt | ut/PBT/ 目录下所有 PBT 测试 |
composer.json→version字段(当前未显式声明,由 Packagist / tag 管理)
- 无
.env文件 - 测试中的密码为硬编码示例值,非真实凭据