承接 qa-data/psr7-http-message 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

qa-data/psr7-http-message

最新稳定版本:v1.1

Composer 安装命令:

composer require qa-data/psr7-http-message

包简介

HTTP message interface

README 文档

README

PSR-7 is HTTP message interface. It's very useful interface especially for middleware / relay pattern. Read more on official PHP-FIG website.

This package is based on a package from the guys at Contributte - PSR-7 HTTP Message, which is based on guzzle/psr7.

Usage

To install latest version of qa-data/psr7-http-message use Composer.

composer require qa-data/psr7-http-message

Psr7Request

The easiest way is to create request using Psr7RequestFactory.

use Contributte\Psr7\Psr7RequestFactory;

$psr7 = Psr7RequestFactory::fromGlobals();

Additional methods (against PSR7 interface):

  • of(RequestInterface $request): self
  • getContents(): mixed
  • getContentsCopy(): mixed
  • getJsonBody(bool $associative = true): mixed
  • getJsonBodyCopy(bool $associative = true): mixed

Psr7ServerRequest

Additional methods (against PSR7 interface):

  • of(ServerRequestInterface $request): self
  • fromGlobals(): self
  • withAttributes(array $attributes): self
  • hasQueryParam(string $name): bool
  • getQueryParam(string $name, mixed $default = null): mixed

Psr7Response

The easiest way is to create request using Psr7ResponseFactory.

use Contributte\Psr7\Psr7ResponseFactory;

$psr7 = Psr7ResponseFactory::fromGlobal();

Additional methods (against PSR7 interface):

  • of(ResponseInterface $response): self
  • fromGlobals(): self
  • appendBody(mixed $body): self
  • rewindBody(): self
  • writeBody(mixed $body): self
  • writeJsonBody(array $data): self
  • writeJsonObject(JsonSerializable $object): self
  • getJsonBody(bool $associative = true): mixed
  • getContents(bool $rewind = true): mixed
  • withHeaders(array $headers): self
  • send(): void
  • sendHeaders(): void
  • sendBody(): void

API

MessageInterface

  • getProtocolVersion: string
  • withProtocolVersion(string $version): static
  • getHeaders(): array
  • hasHeader(string $name): bool
  • getHeader(string $name): string[]
  • getHeaderLine(string $name): string
  • withHeader(string $name, string|string[] $value): static
  • withAddedHeader(string $name, string|string[] $value): static
  • withoutHeader(string $name): static
  • getBody(): StreamInterface
  • withBody(StreamInterface $body): static

RequestInterface << MessageInterface

  • getRequestTarget(): string
  • withRequestTarget($requestTarget): static
  • getMethod(): string
  • withMethod(string $method): static

ServerRequestInterface << RequestInterface

  • getServerParams(): array
  • getCookieParams(): array
  • withCookieParams(array $cookies): static
  • getQueryParams(): array
  • withQueryParams(array $query): static
  • getUploadedFiles(): UploadedFileInterface[]
  • withUploadedFiles(array $uploadedFiles): static
  • getParsedBody(): mixed
  • withParsedBody($data): static
  • getAttributes(): mixed[]
  • getAttribute(string $name, $default = null): mixed
  • withAttribute(string $name, $value): static
  • withoutAttribute(string $name): static

ResponseInterface << MessageInterface

  • getStatusCode(): int
  • withStatus(int $code, string $reasonPhrase = ''): static
  • getReasonPhrase(): string

StreamInterface

  • __toString(): string
  • close(): void
  • detach(): ?resource
  • getSize(): ?int
  • tell(): int
  • eof(): bool
  • isSeekable(): bool
  • seek(int $offset, int $whence = SEEK_SET): void
  • rewind(): void
  • isWritable(): bool
  • write($string): void
  • isReadable(): bool
  • read($length): string
  • getContents(): string
  • getMetadata(?string $key = null): mixed

UriInterface

  • getScheme(): string
  • withScheme(string $scheme): static
  • getAuthority(): string
  • getUserInfo(): string
  • withUserInfo(string $user, ?string $password = null): static
  • getHost(): string
  • withHost(string $host): static
  • getPort(): ?int
  • withPort(?int $port): static
  • getPath(): string
  • withPath(string $path): static
  • getQuery(): string
  • withQuery(string $query): static
  • getFragment(): string
  • withFragment(string $fragment): static
  • __toString(): string

UploadedFileInterface

  • getStream(): StreamInterface
  • moveTo($targetPath): void
  • getSize(): ?int
  • getError(): int
  • getClientFilename(): ?string
  • getClientMediaType(): ?string

统计信息

  • 总下载量: 900
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-01