azjezz / psl
PHP Standard Library
Requires
- php: ~8.4.0 || ~8.5.0
- ext-bcmath: *
- ext-intl: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-sodium: *
- revolt/event-loop: ^1.0.8
Requires (Dev)
- ext-brotli: *
- carthage-software/mago: ^1.15.2
- infection/infection: ^0.32.6
- php-coveralls/php-coveralls: ^2.9.1
- phpbench/phpbench: ^1.5.1
- phpunit/phpunit: ^13.0.5
Suggests
- php-standard-library/phpstan-extension: PHPStan integration
- php-standard-library/psalm-plugin: Psalm integration
Conflicts
- azjezz/psl: *
Replaces
- php-standard-library/ansi: 6.1.1
- php-standard-library/async: 6.1.1
- php-standard-library/binary: 6.1.1
- php-standard-library/cache: 6.1.1
- php-standard-library/channel: 6.1.1
- php-standard-library/cidr: 6.1.1
- php-standard-library/class: 6.1.1
- php-standard-library/collection: 6.1.1
- php-standard-library/comparison: 6.1.1
- php-standard-library/compression: 6.1.1
- php-standard-library/crypto: 6.1.1
- php-standard-library/data-structure: 6.1.1
- php-standard-library/date-time: 6.1.1
- php-standard-library/default: 6.1.1
- php-standard-library/dict: 6.1.1
- php-standard-library/either: 6.1.1
- php-standard-library/encoding: 6.1.1
- php-standard-library/env: 6.1.1
- php-standard-library/file: 6.1.1
- php-standard-library/filesystem: 6.1.1
- php-standard-library/foundation: 6.1.1
- php-standard-library/fun: 6.1.1
- php-standard-library/graph: 6.1.1
- php-standard-library/h2: 6.1.1
- php-standard-library/hash: 6.1.1
- php-standard-library/hpack: 6.1.1
- php-standard-library/html: 6.1.1
- php-standard-library/interface: 6.1.1
- php-standard-library/interoperability: 6.1.1
- php-standard-library/io: 6.1.1
- php-standard-library/ip: 6.1.1
- php-standard-library/iri: 6.1.1
- php-standard-library/iter: 6.1.1
- php-standard-library/json: 6.1.1
- php-standard-library/locale: 6.1.1
- php-standard-library/math: 6.1.1
- php-standard-library/network: 6.1.1
- php-standard-library/observer: 6.1.1
- php-standard-library/option: 6.1.1
- php-standard-library/os: 6.1.1
- php-standard-library/password: 6.1.1
- php-standard-library/process: 6.1.1
- php-standard-library/promise: 6.1.1
- php-standard-library/pseudo-random: 6.1.1
- php-standard-library/punycode: 6.1.1
- php-standard-library/random-sequence: 6.1.1
- php-standard-library/range: 6.1.1
- php-standard-library/regex: 6.1.1
- php-standard-library/result: 6.1.1
- php-standard-library/runtime: 6.1.1
- php-standard-library/secure-random: 6.1.1
- php-standard-library/shell: 6.1.1
- php-standard-library/socks: 6.1.1
- php-standard-library/str: 6.1.1
- php-standard-library/tcp: 6.1.1
- php-standard-library/terminal: 6.1.1
- php-standard-library/tls: 6.1.1
- php-standard-library/trait: 6.1.1
- php-standard-library/tree: 6.1.1
- php-standard-library/type: 6.1.1
- php-standard-library/udp: 6.1.1
- php-standard-library/unix: 6.1.1
- php-standard-library/uri: 6.1.1
- php-standard-library/url: 6.1.1
- php-standard-library/vec: 6.1.1
- dev-next / 6.2.x-dev
- 6.1.x-dev
- 6.1.1
- 6.1.0
- 6.0.x-dev
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.5.x-dev
- 5.5.0
- 5.4.x-dev
- 5.4.0
- 5.3.x-dev
- 5.3.0
- 5.2.x-dev
- 5.2.0
- 5.1.x-dev
- 5.1.0
- 5.0.x-dev
- 5.0.0
- 4.3.x-dev
- 4.3.0
- 4.2.x-dev
- 4.2.1
- 4.2.0
- 4.1.x-dev
- 4.1.0
- 4.0.x-dev
- 4.0.1
- 4.0.0
- 3.3.x-dev
- 3.3.0
- 3.2.x-dev
- 3.2.0
- 3.1.x-dev
- 3.1.0
- 3.0.x-dev
- 3.0.2
- 3.0.1
- 3.0.0
- 2.9.x-dev
- 2.9.1
- 2.9.0
- 2.8.x-dev
- 2.8.0
- 2.7.x-dev
- 2.7.0
- 2.6.x-dev
- 2.6.0
- 2.5.x-dev
- 2.5.0
- 2.4.x-dev
- 2.4.1
- 2.4.0
- 2.3.x-dev
- 2.3.1
- 2.3.0
- 2.2.x-dev
- 2.2.0
- 2.1.x-dev
- 2.1.0
- 2.0.x-dev
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0-rc2
- 2.0.0-rc1
- 1.9.x-dev
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.x-dev
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.x-dev
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.x-dev
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.x-dev
- 1.5.0
- 1.4.x-dev
- 1.4.1
- 1.4.0
- 1.3.x-dev
- 1.3.1
- 1.3.0
- 1.2.x-dev
- 1.2.0
- 1.1.x-dev
- 1.1.1
- 1.1.0
- 1.0.x-dev
- 1.0.0
- 0.1.x-dev
- 0.1.2
- 0.1.1
- 0.1.0
- dev-feat/bin-psl
- dev-feat/dns
- dev-docs-protocols
- dev-feat/smtp
- dev-fix-tests
- dev-changelog/message
- dev-fix/message
- dev-plugin
- dev-feat/message
- dev-upgrade-mago
- dev-pre-release/6.2
- dev-feat/mime
This package is auto-updated.
Last update: 2026-03-24 09:23:48 UTC
README
PSL - PHP Standard Library
A standard library for PHP, inspired by hhvm/hsl. PSL provides a consistent, centralized, well-typed set of APIs covering async, collections, networking, I/O, cryptography, terminal UI, and more - replacing PHP functions and primitives with safer, async-ready alternatives that error predictably.
Installation
composer require php-standard-library/php-standard-library
Requires PHP 8.4+.
Quick Look
Type-safe data validation
Validate and coerce untrusted data with composable type combinators - shapes, unions, optionals - all with zero reflection overhead.
use Psl\Type; $userType = Type\shape([ 'name' => Type\non_empty_string(), 'age' => Type\positive_int(), 'tags' => Type\vec(Type\string()), ]); $user = $userType->coerce($untrustedInput); // array{name: non-empty-string, age: positive-int, tags: list<string>}
Structured concurrency
Run concurrent operations with a single function call. Structured concurrency built on fibers - no promises, no callbacks.
use Psl\Async; use Psl\TCP; use Psl\IO; Async\main(static function(): int { [$a, $b] = Async\concurrently([ static fn() => TCP\connect('api.example.com', 443), static fn() => TCP\connect('db.example.com', 5432), ]); IO\write_error_line('Both connections ready'); return 0; });
Functional collections
Map, filter, sort, and reshape arrays with pure functions. Separate return types for lists and dicts - no more array key confusion.
use Psl\Vec; use Psl\Dict; use Psl\Str; $names = ['alice', 'bob', 'charlie']; Vec\map($names, Str\uppercase(...)); // ['ALICE', 'BOB', 'CHARLIE'] Vec\filter($names, fn($n) => Str\length($n) > 3); // ['alice', 'charlie'] Dict\pull($names, Str\uppercase(...), fn($n) => $n); // {alice: 'ALICE', bob: 'BOB', charlie: 'CHARLIE'}
TCP server in 10 lines
Production-ready networking primitives. TCP, TLS, UDP, Unix sockets - all async, all composable.
use Psl\Async; use Psl\TCP; use Psl\IO; Async\main(static function(): int { $server = TCP\listen('127.0.0.1', 8080); IO\write_error_line('Listening on :8080'); while (true) { $conn = $server->accept(); Async\run(static function() use ($conn) { $conn->writeAll("Hello!\n"); $conn->close(); })->ignore(); } });
Tooling
| Tool | Description |
|---|---|
| Mago | Enhanced type inference for Mago |
| Psalm Plugin | Enhanced type inference for Psalm |
| PHPStan Extension | Enhanced type inference for PHPStan |
Contributing
See CONTRIBUTING.md.
License
MIT - see LICENSE.
