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)
- carthage-software/mago: ^1.13.3
- infection/infection: ^0.32.6
- php-coveralls/php-coveralls: ^2.9.1
- phpbench/phpbench: ^1.4.3
- phpunit/phpunit: ^13.0.5
Suggests
- php-standard-library/phpstan-extension: PHPStan integration
- php-standard-library/psalm-plugin: Psalm integration
- dev-next
- 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-tcp-tls-connector
- dev-mark-5.0.0
- dev-perf/optimize-internals
- dev-clean-up
- dev-increase-msi
- dev-crypto
- dev-license
- dev-missing-interfaces
- dev-more-coverage
- dev-speedup-tests
- dev-clean-tests
- dev-loader
- dev-changelog
- dev-temp-dir
- dev-binary
- dev-canonicalize-path
- dev-dead-code
- dev-datetime-refactor
- dev-banner
- dev-docs-deploy
- dev-documentation
- dev-update-dependencies
- dev-ansi-mode
- dev-feat/terminal
- dev-feat/ansi
- dev-split-udp
- dev-testing
- dev-tcp-udp-tls
- dev-phpunit-13
- dev-vec-flatten
- dev-interper
- dev-range-fix
- dev-canonicalize-tmp-dir
- dev-cmd-process
- dev-fix-tests
- dev-prepare-next-mago
- dev-catch-error
- dev-feat/network-tls
This package is auto-updated.
Last update: 2026-03-05 16:06:01 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 azjezz/psl
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.
