Search by

manychois / php-strong

manychois

A utility library for PHP to help you write strong-typed code.

Package info

github.com/manychois/php-strong

pkg:composer/manychois/php-strong

Statistics

Installs: 30

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 3

v0.0.2 2026-08-25 12:27 UTC

This package is auto-updated.

Last update: 2026-09-01 20:21:09 UTC


README

php-strong provides solid, strongly-typed implementations of the PHP-FIG PSR interfaces, one sub-namespace per problem area rather than per PSR, so utilities no PSR covers live beside the PSR classes they belong with. The goal is to cover every PSR that defines an interface.

Targets PHP 8.5+, namespace Manychois\PhpStrong, PSR-4 autoloading.

Installation

composer require manychois/php-strong

Modules

Each module owns one problem area. Where a PSR governs it, the module implements that PSR; some modules also ship utilities no PSR covers.

PSR Namespace Summary Docs
PSR-3 Logger Manychois\PhpStrong\Logging Logger dispatching immutable Log objects to handlers (stream, console, in-memory) with pluggable formatters and {placeholder} interpolation. docs/logging.md
PSR-6 Cache Manychois\PhpStrong\Cache FileCachePool storing one file per key under a directory (sha-256 sharded paths, atomic writes, a request-scoped read memo) and MemoryCachePool keeping entries in memory; both support deferred items and prune(), with expiry driven by an injected PSR-20 clock. docs/cache.md
PSR-16 Simple Cache Manychois\PhpStrong\Cache SimpleCache, a PSR-16 adapter over any PSR-6 pool, including both of the above. docs/cache.md
PSR-7 HTTP Message + PSR-17 Factories Manychois\PhpStrong\Http Immutable Request, ServerRequest (with fromGlobals()), Response, Stream, UploadedFile, Uri, Method/StatusCode enums, and the five PSR-17 factories. docs/http.md
PSR-18 HTTP Client Manychois\PhpStrong\Http cURL-backed Client configured via RequestOptions (timeouts, redirects, TLS verification, proxy, user agent, CA bundle); returns responses for every status code and throws RequestException/NetworkException per the PSR-18 contract, plus a non-PSR sendAsync() returning PendingRequest handles for concurrent requests over curl_multi. docs/http.md
PSR-15 Handlers & Middleware Manychois\PhpStrong\Http MiddlewarePipeline, a request handler dispatching middleware in order to a fallback handler, with optional lazy resolution of middleware service ids from a PSR-11 container. docs/http.md
PSR-11 Container Manychois\PhpStrong\DependencyInjection ContainerBuilder (singleton/factory/alias/opt-in autowire/aware setter hooks) producing an immutable, lazily-resolving Container with circular-dependency detection. docs/dependency-injection.md
PSR-20 Clock Manychois\PhpStrong\Time UtcClock (always UTC) and TestClock (frozen/advanceable instant for deterministic tests). docs/time.md
PSR-14 Event Dispatcher Manychois\PhpStrong\Events EventDispatcher calling listeners returned by any PSR-14 provider; ListenerProvider matches listeners by type (including parents/interfaces), orders by priority, and supports deferred [$serviceId, $method] listeners resolved from an optional container. docs/events.md
PSR-13 Links Manychois\PhpStrong\Links Immutable, evolvable Link and LinkProvider, with isTemplated() derived from a strict RFC 6570 check of the href. docs/links.md

Every accepted PSR that defines an interface is now covered.

Utilities

Namespace Summary Docs
Manychois\PhpStrong\Collections DataReader, strongly typed access to an untyped array or object with dot-notation keys and strict/converting/nullable accessors, plus the Iter (lazy) and Seq (eager) iterable utilities. docs/collections.md
Manychois\PhpStrong\Http NativeSession, a lazily started $_SESSION wrapper whose SessionInterface extends DataReaderInterface, so session data is read with the same strongly typed, dot-notation accessors; plus Cookie, CookieBag and CookieStore/CookieAwareClient for reading, queuing and remembering cookies on either side of a request. Plus SapiEmitter, which sends a finished response to the SAPI and is the one place the response's headers and PHP's own queued cookies are merged. docs/http.md
Manychois\PhpStrong\Texts Regex, a value object wrapping one pattern, whose match(), matchAll(), replace(), replaceCallback() and split() raise RuntimeException instead of returning false; matches come back as MatchResult/Capture objects carrying the captured text and its byte offset. docs/texts.md
Manychois\PhpStrong\Time DayOfWeek and Month, calendar enums numbered to match DateTimeInterface::format(), with wrapping arithmetic and leap-aware month lengths. docs/time.md

Development

composer code   # phpcbf + phpcs + phpstan
composer test   # phpunit with coverage

License

MIT.