create-psr17-http-factory
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-psr17-http-factory" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-b8a8e92d1f86eb837ce2ef873bacf51cdb6dee3dbf1290fbfaddfea51a5a1e32. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Generate a PSR-17 HTTP factory implementation for PHP 8.4. Create implementations for RequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ServerRequestFactoryInterface, and UploadedFileFactoryInterface, including corresponding unit tests.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Generates PSR-17 HTTP Factories implementation for PHP 8.4. Creates RequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ServerRequestFactoryInterface, UploadedFileFactoryInterface. Includes unit tests.
- Audience
- Creating PSR-7 messages in DI containers Testing HTTP interactions Building HTTP frameworks Decoupling from specific PSR-7 implementations
- Testing
- Not tested
Browse files
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"
}
}Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 PSR-17 HTTP 工厂实现生成,适用于 PHP 开发者构建 HTTP 框架、测试、DI 容器等场景
- 具有明确的技术实用价值,属于通用工具范畴
Highlights
- description 明确描述了生成 PSR-17 HTTP 工厂实现的功能
- 覆盖 RequestFactoryInterface、ResponseFactoryInterface 等核心接口,触发词精准
Highlights
- 文档结构清晰,包含 Overview、When to Use、Template、Usage Example、DI Container Registration、Requirements 等完整章节
- 提供了端到端示例和依赖说明
Highlights
- 提供了完整的 PHP 实现代码,包含异常处理(如文件打开失败、资源读取失败)
- 参数使用合理,工具来源明确(PSR 标准)
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- api.example.com
- example.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.