Explore PSL 5.0: New Crypto, Binary, Network Stack & Performance Boosts for PHP 8.4+

PSL 5.0 (codenamed Crown) introduces ten new components—including a libsodium‑based crypto library, a binary Reader/Writer API, a fully rewritten network stack, and enhanced terminal UI—while delivering up to 100% performance gains and requiring PHP 8.4 or newer.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
Explore PSL 5.0: New Crypto, Binary, Network Stack & Performance Boosts for PHP 8.4+

PSL 5.0 Overview

PSL 5.0 (codenamed Crown ) is the largest release of the PHP Standard Library. It adds ten new components, a complete rewrite of the network stack, and significant performance improvements across the library. The release requires PHP 8.4 or newer.

Crypto Component

A full‑featured cryptography library built on libsodium provides type‑safe APIs for symmetric and asymmetric encryption, digital signatures, AEAD, key derivation (KDF, HKDF), key exchange, and stream ciphers.

use Psl\Crypto\Symmetric;

$key = Symmetric\generate_key();
$ciphertext = Symmetric\seal('Hello, World!', $key);
$plaintext = Symmetric\open($ciphertext, $key);
// 'Hello, World!'
use Psl\Crypto\Signing;

$keyPair = Signing\generate_key_pair();
$signature = Signing\sign('This message is authentic.', $keyPair->secretKey);
$valid = Signing\verify($signature, 'This message is authentic.', $keyPair->publicKey);
// true

Binary Component

The streaming Reader/Writer API enables structured binary parsing and encoding, supporting integers, floats, and strings in any endianness—ideal for protocol parsers.

use Psl\Binary\{Reader, Writer, Endianness};

$data = (new Writer(endianness: Endianness::Big))
    ->u8(1)               // version
    ->u16(0x0042)         // type
    ->u32(5)              // payload length
    ->bytes('Hello')
    ->toString();

$reader = new Reader($data, Endianness::Big);
$version = $reader->u8();      // 1
$type    = $reader->u16();      // 0x0042
$length  = $reader->u32();      // 5
$payload = $reader->bytes($length); // 'Hello'

Network Stack Rewrite

The Network, TCP, TLS, UDP, Unix, CIDR, and Socks components have been rebuilt from scratch, offering connection pooling, retry logic, socket pairs, and first‑class TLS support.

use Psl\TCP;

$listener = TCP\listen('127.0.0.1');
$connection = $listener->accept();
$data = $connection->readAll();
$connection->writeAll($data);
use Psl\TLS;

$tls = TLS\connect('example.com', 443);
$tls->writeAll("GET / HTTP/1.0
Host: example.com

");
$tls->shutdown();
$response = $tls->readAll();
use Psl\CIDR;

$block = new CIDR\Block('192.168.1.0/24');
$block->contains('192.168.1.100'); // true
$block->contains('192.168.2.1');   // false

Process Component

Asynchronous process management mirrors Rust’s Command API, providing a safer, higher‑level alternative to proc_open. The Psl\Shell\execute function is built on top of this.

use Psl\Process\Command;

$output = Command::create('echo')
    ->withArguments(['Hello', 'from', 'process'])
    ->output();

if ($output->status->isSuccessful()) {
    $output->stdout; // 'Hello from process'
}

Terminal & ANSI Component

A complete terminal UI framework supports buffered rendering, layout, widgets, keyboard/mouse events, and ANSI styling, enabling rich interactive TUI applications in pure PHP.

system-monitor
system-monitor

Example system‑monitor UI source file: https://github.com/azjezz/psl/blob/next/examples/terminal/system-monitor.php

snake
snake

Snake game example source file: https://github.com/azjezz/psl/blob/next/examples/terminal/snake.php

DateTime Enhancements

New Period and Interval types allow representation and manipulation of time spans.

use Psl\DateTime;

$period = DateTime\Period::fromParts(years: 1, months: 6, days: 15);
$period->toIso8601(); // 'P1Y6M15D'

$start = DateTime\DateTime::fromParts(DateTime\Timezone::UTC, 2024, 3, 15);
$end   = DateTime\DateTime::fromParts(DateTime\Timezone::UTC, 2025, 7, 20);
$between = DateTime\Period::between($start, $end);
// 1 year(s), 4 month(s), 5 day(s)

Performance Optimizations

Components such as Vec, Dict, Str, Iter, and Type have been tuned; some benchmarks show up to a 100% speed increase.

Breaking Changes

Minimum PHP version raised to 8.4 (PHP 8.3 support removed).

Network stack fully rewritten (Network, TCP, UDP, Unix, CIDR, Socks). Psl\Env\temp_dir() now always returns a normalized path. Filesystem\create_temporary_file() now normalizes temporary directory paths.

Migrated test suite to PHPUnit 13.

Bug Fixes

Vec\range()

now uses strict floating‑point comparison to preserve precision.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

NetworkPHPCryptoPSL
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.