manychois / php-strong
A utility library for PHP to help you write strong-typed code.
v0.0.2
2026-08-25 12:27 UTC
Requires
- php: >=8.5
- ext-curl: *
- psr/cache: ^3
- psr/clock: ^1
- psr/container: ^2.0.2
- psr/event-dispatcher: ^1.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.1
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- psr/link: ^2
- psr/log: ^3.0
- psr/simple-cache: ^3
Requires (Dev)
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.1.46
- phpstan/phpstan-phpunit: ^2.0.16
- phpstan/phpstan-strict-rules: ^2.0.10
- phpunit/phpunit: ^12.5.15 || ^13.0.0
- slevomat/coding-standard: ^8.22.1
- squizlabs/php_codesniffer: ^3.13.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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.