acc-create-psr17-http-factory

Generates PSR-17 HTTP Factories implementation for PHP 8.5. Creates RequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ServerRequestFactoryInterface, UploadedFileFactoryInterface. Includes unit tests.

16 stars

Best use case

acc-create-psr17-http-factory is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Generates PSR-17 HTTP Factories implementation for PHP 8.5. Creates RequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ServerRequestFactoryInterface, UploadedFileFactoryInterface. Includes unit tests.

Teams using acc-create-psr17-http-factory should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/acc-create-psr17-http-factory/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/acc-create-psr17-http-factory/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/acc-create-psr17-http-factory/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How acc-create-psr17-http-factory Compares

Feature / Agentacc-create-psr17-http-factoryStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Generates PSR-17 HTTP Factories implementation for PHP 8.5. Creates RequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ServerRequestFactoryInterface, UploadedFileFactoryInterface. Includes unit tests.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 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
<?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
<?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
<?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

```json
{
    "require": {
        "psr/http-factory": "^1.1",
        "psr/http-message": "^2.0"
    }
}
```

Related Skills

agent-ops-create-python-project

16
from diegosouzapw/awesome-omni-skill

Create a plan and issues for implementation of a production-ready Python project with proper structure, tooling, and best practices.

acc-create-use-case

16
from diegosouzapw/awesome-omni-skill

Generates Application Use Cases for PHP 8.5. Creates orchestration services that coordinate domain objects, handle transactions, and dispatch events. Includes unit tests.

acc-create-state

16
from diegosouzapw/awesome-omni-skill

Generates State pattern for PHP 8.5. Creates state machines with context, state interface, and concrete states for behavior changes. Includes unit tests.

acc-create-saga-pattern

16
from diegosouzapw/awesome-omni-skill

Generates Saga pattern components for PHP 8.5. Creates Saga interfaces, steps, orchestrator, state management, and compensation logic with unit tests.

acc-create-retry-pattern

16
from diegosouzapw/awesome-omni-skill

Generates Retry pattern for PHP 8.5. Creates resilience component with exponential backoff, jitter, and configurable retry strategies. Includes unit tests.

acc-create-responder

16
from diegosouzapw/awesome-omni-skill

Generates ADR Responder classes for PHP 8.5. Creates HTTP response builders with PSR-7/PSR-17 support. Includes unit tests.

acc-create-repository

16
from diegosouzapw/awesome-omni-skill

Generates DDD Repository interfaces and implementation stubs for PHP 8.5. Creates domain interfaces in Domain layer, implementation in Infrastructure.

acc-create-rate-limiter

16
from diegosouzapw/awesome-omni-skill

Generates Rate Limiter pattern for PHP 8.5. Creates request throttling with token bucket, sliding window, and fixed window algorithms. Includes unit tests.

acc-create-psr6-cache

16
from diegosouzapw/awesome-omni-skill

Generates PSR-6 Cache implementation for PHP 8.5. Creates CacheItemPoolInterface and CacheItemInterface implementations with TTL handling and deferred saves. Includes unit tests.

acc-create-psr3-logger

16
from diegosouzapw/awesome-omni-skill

Generates PSR-3 Logger implementation for PHP 8.5. Creates LoggerInterface implementations with log levels, context interpolation, and LoggerAwareTrait usage. Includes unit tests.

acc-create-psr20-clock

16
from diegosouzapw/awesome-omni-skill

Generates PSR-20 Clock implementation for PHP 8.5. Creates ClockInterface implementations including SystemClock, FrozenClock, and OffsetClock for time abstraction and testing. Includes unit tests.

acc-create-psr16-simple-cache

16
from diegosouzapw/awesome-omni-skill

Generates PSR-16 Simple Cache implementation for PHP 8.5. Creates CacheInterface with get/set/delete operations and TTL handling. Includes unit tests.