create-psr17-http-factory
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-psr17-http-factory":https://skillpi.com/zh/skills/deepskill-b8a8e92d1f86eb837ce2ef873bacf51cdb6dee3dbf1290fbfaddfea51a5a1e32。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 PHP 8.4 生成 PSR-17 HTTP 工厂实现。创建 RequestFactoryInterface、ResponseFactoryInterface、StreamFactoryInterface、UriFactoryInterface、ServerRequestFactoryInterface 与 UploadedFileFactoryInterface 的实现,并包含相应的单元测试。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: create-psr17-http-factory
description: Generates PSR-17 HTTP Factories implementation for PHP 8.4. Creates RequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ServerRequestFactoryInterface, UploadedFileFactoryInterface. Includes unit tests.PSR-17 HTTP Factories Generator
Overview
Generates PSR-17 compliant HTTP factory implementations for creating PSR-7 objects.
When to Use
- Creating PSR-7 messages in DI containers
- Testing HTTP interactions
- Building HTTP frameworks
- Decoupling from specific PSR-7 implementations
Template: HTTP Factory
<?php
declare(strict_types=1);
namespace App\Infrastructure\Http\Factory;
use App\Infrastructure\Http\Message\Request;
use App\Infrastructure\Http\Message\Response;
use App\Infrastructure\Http\Message\ServerRequest;
use App\Infrastructure\Http\Message\Stream;
use App\Infrastructure\Http\Message\UploadedFile;
use App\Infrastructure\Http\Message\Uri;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileFactoryInterface;
use Psr\Http\Message\UploadedFileInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
final readonly class HttpFactory implements
RequestFactoryInterface,
ResponseFactoryInterface,
ServerRequestFactoryInterface,
StreamFactoryInterface,
UploadedFileFactoryInterface,
UriFactoryInterface
{
public function createRequest(string $method, $uri): RequestInterface
{
return new Request(
$method,
$uri instanceof UriInterface ? $uri : $this->createUri($uri),
);
}
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
{
return new Response($code, $reasonPhrase);
}
public function createServerRequest(
string $method,
$uri,
array $serverParams = [],
): ServerRequestInterface {
return new ServerRequest(
$method,
$uri instanceof UriInterface ? $uri : $this->createUri($uri),
serverParams: $serverParams,
);
}
public function createStream(string $content = ''): StreamInterface
{
return new Stream($content);
}
public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
{
$resource = fopen($filename, $mode);
if ($resource === false) {
throw new \RuntimeException("Cannot open file: {$filename}");
}
return $this->createStreamFromResource($resource);
}
public function createStreamFromResource($resource): StreamInterface
{
$content = stream_get_contents($resource);
if ($content === false) {
throw new \RuntimeException('Cannot read from resource');
}
return new Stream($content);
}
public function createUploadedFile(
StreamInterface $stream,
?int $size = null,
int $error = UPLOAD_ERR_OK,
?string $clientFilename = null,
?string $clientMediaType = null,
): UploadedFileInterface {
$tmpFile = tempnam(sys_get_temp_dir(), 'upload_');
file_put_contents($tmpFile, (string) $stream);
return new UploadedFile(
$tmpFile,
$size ?? $stream->getSize(),
$error,
$clientFilename,
$clientMediaType,
);
}
public function createUri(string $uri = ''): UriInterface
{
return Uri::fromString($uri);
}
}
Usage Example
<?php
use App\Infrastructure\Http\Factory\HttpFactory;
$factory = new HttpFactory();
// Create request
$request = $factory->createRequest('GET', 'https://api.example.com/users');
$request = $request->withHeader('Accept', 'application/json');
// Create response
$response = $factory->createResponse(200);
$response = $response
->withHeader('Content-Type', 'application/json')
->withBody($factory->createStream(json_encode(['status' => 'ok'])));
// Create server request
$serverRequest = $factory->createServerRequest('POST', '/api/users', $_SERVER);
// Create URI
$uri = $factory->createUri('https://example.com/path?query=value');
// Create stream from file
$stream = $factory->createStreamFromFile('/path/to/file.txt');
DI Container Registration
<?php
// Symfony services.yaml
services:
App\Infrastructure\Http\Factory\HttpFactory:
public: true
Psr\Http\Message\RequestFactoryInterface:
alias: App\Infrastructure\Http\Factory\HttpFactory
Psr\Http\Message\ResponseFactoryInterface:
alias: App\Infrastructure\Http\Factory\HttpFactory
Psr\Http\Message\StreamFactoryInterface:
alias: App\Infrastructure\Http\Factory\HttpFactory
Psr\Http\Message\UriFactoryInterface:
alias: App\Infrastructure\Http\Factory\HttpFactory
Psr\Http\Message\ServerRequestFactoryInterface:
alias: App\Infrastructure\Http\Factory\HttpFactory
Psr\Http\Message\UploadedFileFactoryInterface:
alias: App\Infrastructure\Http\Factory\HttpFactory
Requirements
{
"require": {
"psr/http-factory": "^1.1",
"psr/http-message": "^2.0"
}
}当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 PSR-17 HTTP 工厂实现生成,适用于 PHP 开发者构建 HTTP 框架、测试、DI 容器等场景
- 具有明确的技术实用价值,属于通用工具范畴
亮点
- description 明确描述了生成 PSR-17 HTTP 工厂实现的功能
- 覆盖 RequestFactoryInterface、ResponseFactoryInterface 等核心接口,触发词精准
亮点
- 文档结构清晰,包含 Overview、When to Use、Template、Usage Example、DI Container Registration、Requirements 等完整章节
- 提供了端到端示例和依赖说明
亮点
- 提供了完整的 PHP 实现代码,包含异常处理(如文件打开失败、资源读取失败)
- 参数使用合理,工具来源明确(PSR 标准)
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- api.example.com
- example.com
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。