azjezz/psl

This package is abandoned and no longer maintained. The author suggests using the php-standard-library/php-standard-library package instead.

PHP Standard Library

Maintainers

๐Ÿ‘ azjezz

Package info

github.com/php-standard-library/php-standard-library

pkg:composer/azjezz/psl

Fund package maintenance!

azjezz

veewee

Statistics

Installs: 12โ€‰423โ€‰978

Dependents: 54

Suggesters: 2

Stars: 1โ€‰548

Open Issues: 22

6.2.1 2026-05-23 22:30 UTC

Requires

Requires (Dev)

Suggests

Provides

None

Conflicts

Replaces

MIT 331f3ab363508825e62c42725f96c091bcceb970

  • azjezz <azjezz.woop@protonmail.com>

This package is auto-updated.

Last update: 2026-06-12 21:21:16 UTC


README

๐Ÿ‘ PSL

PSL - PHP Standard Library

๐Ÿ‘ Unit tests status
๐Ÿ‘ Static analysis status
๐Ÿ‘ Coding standards status
๐Ÿ‘ CII Best Practices
๐Ÿ‘ Coverage Status
๐Ÿ‘ MSI
๐Ÿ‘ Total Downloads
๐Ÿ‘ Latest Stable Version
๐Ÿ‘ License

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.

Documentation ยท Sponsor

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.