PHPackages                             php-standard-library/php-standard-library - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. php-standard-library/php-standard-library

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

php-standard-library/php-standard-library
=========================================

PHP Standard Library

6.1.1(2d ago)1.5k6.6k—0%83[18 issues](https://github.com/php-standard-library/php-standard-library/issues)MITPHPPHP ~8.4.0 || ~8.5.0CI passing

Since Dec 14Pushed today23 watchersCompare

[ Source](https://github.com/php-standard-library/php-standard-library)[ Packagist](https://packagist.org/packages/php-standard-library/php-standard-library)[ GitHub Sponsors](https://github.com/azjezz)[ GitHub Sponsors](https://github.com/veewee)[ RSS](/packages/php-standard-library-php-standard-library/feed)WikiDiscussions next Synced today

READMEChangelog (10)Dependencies (6)Versions (158)Used By (0)

 [![PSL](docs/resources/banner.png)](docs/resources/banner.png)

PSL - PHP Standard Library
==========================

[](#psl---php-standard-library)

[![Unit tests status](https://github.com/php-standard-library/php-standard-library/workflows/unit%20tests/badge.svg)](https://github.com/php-standard-library/php-standard-library/workflows/unit%20tests/badge.svg)[![Static analysis status](https://github.com/php-standard-library/php-standard-library/workflows/static%20analysis/badge.svg)](https://github.com/php-standard-library/php-standard-library/workflows/static%20analysis/badge.svg)[![Coding standards status](https://github.com/php-standard-library/php-standard-library/workflows/coding%20standards/badge.svg)](https://github.com/php-standard-library/php-standard-library/workflows/coding%20standards/badge.svg)[![CII Best Practices](https://camo.githubusercontent.com/0cc47258201be7745e41e499a554f345185f7d38d261cff93668f3c3ad8ee4f0/68747470733a2f2f626573747072616374696365732e636f7265696e6672617374727563747572652e6f72672f70726f6a656374732f343232382f6261646765)](https://bestpractices.coreinfrastructure.org/projects/4228)[![Coverage Status](https://camo.githubusercontent.com/cbff074d8093ae9078ddfcbac2afd6ec4edaf90dc0a47dd9d7f41d65ef0d4352/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7068702d7374616e646172642d6c6962726172792f7068702d7374616e646172642d6c6962726172792f62616467652e737667)](https://coveralls.io/github/php-standard-library/php-standard-library)[![MSI](https://camo.githubusercontent.com/a1a9c59f8ecd1befa00de13bf803b3e0c1f36701643e35fa0bead1520d6e80e3/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532467068702d7374616e646172642d6c6962726172792532467068702d7374616e646172642d6c6962726172792532466e657874)](https://dashboard.stryker-mutator.io/reports/github.com/php-standard-library/php-standard-library/next)[![Total Downloads](https://camo.githubusercontent.com/09fd9bd5ddd33051736cd88ca30001f30f9b3bf875761d8225064ef72849fbd3/68747470733a2f2f706f7365722e707567782e6f72672f7068702d7374616e646172642d6c6962726172792f7068702d7374616e646172642d6c6962726172792f642f746f74616c2e737667)](https://packagist.org/packages/php-standard-library/php-standard-library)[![Latest Stable Version](https://camo.githubusercontent.com/f63749d9ca442397b378d9c1de3521bbb3297eed8c38a586b082e3eeedc2ec75/68747470733a2f2f706f7365722e707567782e6f72672f7068702d7374616e646172642d6c6962726172792f7068702d7374616e646172642d6c6962726172792f762f737461626c652e737667)](https://packagist.org/packages/php-standard-library/php-standard-library)[![License](https://camo.githubusercontent.com/ac363178fdf95cd6f6150be18d86d540fe34de67a3d582de6bcf0abe744a1bd6/68747470733a2f2f706f7365722e707567782e6f72672f7068702d7374616e646172642d6c6962726172792f7068702d7374616e646172642d6c6962726172792f6c6963656e73652e737667)](https://packagist.org/packages/php-standard-library/php-standard-library)

A standard library for PHP, inspired by [hhvm/hsl](https://github.com/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](https://php-standard-library.dev)** · **[Sponsor](https://github.com/sponsors/azjezz)**

Installation
------------

[](#installation)

```
composer require php-standard-library/php-standard-library
```

Requires PHP 8.4+.

Quick Look
----------

[](#quick-look)

### Type-safe data validation

[](#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}
```

### Structured concurrency

[](#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

[](#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

[](#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
-------

[](#tooling)

ToolDescription[Mago](https://mago.carthage.software/tools/analyzer/configuration-reference#available-plugins)Enhanced type inference for Mago[Psalm Plugin](https://github.com/php-standard-library/psalm-plugin)Enhanced type inference for Psalm[PHPStan Extension](https://github.com/php-standard-library/phpstan-extension)Enhanced type inference for PHPStanContributing
------------

[](#contributing)

See [CONTRIBUTING.md](./CONTRIBUTING.md).

License
-------

[](#license)

MIT - see [LICENSE](./LICENSE).

###  Health Score

72

—

ExcellentBetter than 100% of packages

Maintenance100

Actively maintained with recent releases

Popularity52

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity89

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 77.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Recently: every ~0 days

Total

108

Last Release

2d ago

Major Versions

1.6.x-dev → 2.0.02022-05-07

2.9.x-dev → 3.0.02024-09-03

3.3.x-dev → 4.0.02025-09-15

4.3.x-dev → 5.0.02026-03-04

5.5.x-dev → 6.0.02026-03-17

PHP version history (12 changes)0.1.0PHP ^7.4 || ^8.0

1.7.0PHP ^8.0

1.9.1PHP ~8.0.0 || ~8.1.0

1.6.2PHP ^7.4 || ~8.0.0 || ~8.1.0

2.0.0-rc1PHP ~8.1.0

2.0.4PHP ~8.1.0 || ~8.2.0

2.8.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

3.0.0PHP ~8.2.0 || ~8.3.0

3.1.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0

4.0.0PHP ~8.3.0 || ~8.4.0

4.2.0PHP ~8.3.0 || ~8.4.0 || ~8.5.0

5.0.0PHP ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8489d7c85bfa7c637b8e13484f3f659652aea0568b6e7f9e66edeb0649b5a2f1?d=identicon)[azjezz](/maintainers/azjezz)

---

Top Contributors

[![azjezz](https://avatars.githubusercontent.com/u/29315886?v=4)](https://github.com/azjezz "azjezz (695 commits)")[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (58 commits)")[![Ocramius](https://avatars.githubusercontent.com/u/154256?v=4)](https://github.com/Ocramius "Ocramius (34 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (30 commits)")[![jrmajor](https://avatars.githubusercontent.com/u/26096713?v=4)](https://github.com/jrmajor "jrmajor (10 commits)")[![dragosprotung](https://avatars.githubusercontent.com/u/1081073?v=4)](https://github.com/dragosprotung "dragosprotung (9 commits)")[![simPod](https://avatars.githubusercontent.com/u/327717?v=4)](https://github.com/simPod "simPod (9 commits)")[![devnix](https://avatars.githubusercontent.com/u/1777519?v=4)](https://github.com/devnix "devnix (8 commits)")[![ntzm](https://avatars.githubusercontent.com/u/3888578?v=4)](https://github.com/ntzm "ntzm (7 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (5 commits)")[![gsteel](https://avatars.githubusercontent.com/u/2803720?v=4)](https://github.com/gsteel "gsteel (5 commits)")[![BackEndTea](https://avatars.githubusercontent.com/u/14289961?v=4)](https://github.com/BackEndTea "BackEndTea (4 commits)")[![hasseneb](https://avatars.githubusercontent.com/u/36151552?v=4)](https://github.com/hasseneb "hasseneb (3 commits)")[![KennedyTedesco](https://avatars.githubusercontent.com/u/999232?v=4)](https://github.com/KennedyTedesco "KennedyTedesco (3 commits)")[![phpjob](https://avatars.githubusercontent.com/u/6864389?v=4)](https://github.com/phpjob "phpjob (2 commits)")[![nzour](https://avatars.githubusercontent.com/u/45079391?v=4)](https://github.com/nzour "nzour (2 commits)")[![yivi](https://avatars.githubusercontent.com/u/1815039?v=4)](https://github.com/yivi "yivi (2 commits)")[![Zerogiven](https://avatars.githubusercontent.com/u/389319?v=4)](https://github.com/Zerogiven "Zerogiven (1 commits)")[![b1rdex](https://avatars.githubusercontent.com/u/312855?v=4)](https://github.com/b1rdex "b1rdex (1 commits)")[![bcremer](https://avatars.githubusercontent.com/u/55820?v=4)](https://github.com/bcremer "bcremer (1 commits)")

---

Tags

ansiasynccollectiondata-structuresencodinggrapheme-clusterhtmliojsonmathmultibyte-stringsnon-blockingpassword-hashingphppseudo-randomsecure-randomshellstandard-libraryterminal-uitype-assertion

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/php-standard-library-php-standard-library/health.svg)

```
[![Health](https://phpackages.com/badges/php-standard-library-php-standard-library/health.svg)](https://phpackages.com/packages/php-standard-library-php-standard-library)
```

###  Alternatives

[amphp/process

A fiber-aware process manager based on Amp and Revolt.

25550.2M46](/packages/amphp-process)[topthink/think-worker

workerman extend for thinkphp

202224.6k9](/packages/topthink-think-worker)[telephantast/message-bus

Thesis Message Bus

161.1k6](/packages/telephantast-message-bus)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
