PHPackages                             php-ds/php-ds - 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-ds/php-ds

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

php-ds/php-ds
=============

Specialized data structures as alternatives to the PHP array

v2.0.1(1mo ago)4109.5M↓36.5%49[10 issues](https://github.com/php-ds/polyfill/issues)[3 PRs](https://github.com/php-ds/polyfill/pulls)20MITPHPPHP &gt;=8.2CI failing

Since Mar 4Pushed 1mo ago18 watchersCompare

[ Source](https://github.com/php-ds/polyfill)[ Packagist](https://packagist.org/packages/php-ds/php-ds)[ RSS](/packages/php-ds-php-ds/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)Dependencies (3)Versions (20)Used By (20)

Data Structures for PHP
=======================

[](#data-structures-for-php)

[![Build Status](https://github.com/php-ds/polyfill/workflows/CI/badge.svg)](https://github.com/php-ds/polyfill/actions?query=workflow%3A%22CI%22+branch%3Amaster)[![Packagist](https://camo.githubusercontent.com/d1331fa5bc6c90d814e2871eece5390e904400042bca837b756c9a375420564a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d64732f7068702d64732e737667)](https://packagist.org/packages/php-ds/php-ds)

This is a v2 compatibility polyfill for the [extension](https://github.com/php-ds/extension). You should include this package as a dependency of your project to ensure that your codebase would still be functional in an environment where the extension is not installed. The polyfill will not be loaded if the extension is installed and enabled.

Requires PHP &gt;= 8.2.

Types
-----

[](#types)

- `Ds\Seq` -- ordered sequence of values (replaces Vector and Deque from v1)
- `Ds\Map` -- ordered map of key-value pairs
- `Ds\Set` -- unordered set of unique values
- `Ds\Heap` -- configurable heap, max-heap by default
- `Ds\Pair` -- readonly key-value pair
- `Ds\Key` -- interface for custom key equality (replaces Hashable from v1)

Functional Constructors
-----------------------

[](#functional-constructors)

Convenience functions are available as an alternative to using `new`:

```
\Ds\seq([1, 2, 3]);
\Ds\map(['a' => 1, 'b' => 2]);
\Ds\set([1, 2, 3]);
\Ds\heap([3, 1, 2]);
```

Install
-------

[](#install)

```
composer require php-ds/php-ds
```

You can also *require* that the extension be installed using `ext-ds`.

Test
----

[](#test)

```
composer install
composer test

```

Make sure that the *ds* extension is not enabled, as the polyfill will not be loaded if it is. The test output will indicate whether the extension is active.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for more information.

### Credits

[](#credits)

- [Rudi Theunissen](https://github.com/rtheunissen)
- [Joe Watkins](https://github.com/krakjoe)

### License

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.

###  Health Score

75

—

ExcellentBetter than 100% of packages

Maintenance90

Actively maintained with recent releases

Popularity66

Solid adoption and visibility

Community47

Growing community involvement

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 71.9% 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 ~238 days

Recently: every ~111 days

Total

16

Last Release

48d ago

Major Versions

1.2.x-dev → 2.0.x-dev2016-12-19

v1.8.0 → v2.0.02026-04-12

PHP version history (6 changes)v1.0.2PHP &gt;=7

v1.0.3PHP &gt;=7.0.0

v1.4.0PHP ^7.3 || ~8.0.0 || ~8.1.0

v1.4.1PHP &gt;=7.0

v1.6.0PHP &gt;=7.4

v1.8.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/761df764fa80c32031884a5dd2376cf7e70c0fa152eaa141fd68f12b4a761b9f?d=identicon)[rtheunissen](/maintainers/rtheunissen)

---

Top Contributors

[![rtheunissen](https://avatars.githubusercontent.com/u/809191?v=4)](https://github.com/rtheunissen "rtheunissen (169 commits)")[![simPod](https://avatars.githubusercontent.com/u/327717?v=4)](https://github.com/simPod "simPod (20 commits)")[![dantudor](https://avatars.githubusercontent.com/u/1281127?v=4)](https://github.com/dantudor "dantudor (19 commits)")[![fanlei](https://avatars.githubusercontent.com/u/1195782?v=4)](https://github.com/fanlei "fanlei (5 commits)")[![rudi-augment](https://avatars.githubusercontent.com/u/240759057?v=4)](https://github.com/rudi-augment "rudi-augment (3 commits)")[![iggyvolz](https://avatars.githubusercontent.com/u/2197376?v=4)](https://github.com/iggyvolz "iggyvolz (2 commits)")[![billythekid](https://avatars.githubusercontent.com/u/330170?v=4)](https://github.com/billythekid "billythekid (2 commits)")[![ZebulanStanphill](https://avatars.githubusercontent.com/u/19592990?v=4)](https://github.com/ZebulanStanphill "ZebulanStanphill (2 commits)")[![ricardoboss](https://avatars.githubusercontent.com/u/6266356?v=4)](https://github.com/ricardoboss "ricardoboss (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![SerafimArts](https://avatars.githubusercontent.com/u/2461257?v=4)](https://github.com/SerafimArts "SerafimArts (1 commits)")[![silencedis](https://avatars.githubusercontent.com/u/12890938?v=4)](https://github.com/silencedis "silencedis (1 commits)")[![someniatko](https://avatars.githubusercontent.com/u/15856706?v=4)](https://github.com/someniatko "someniatko (1 commits)")[![Nebual](https://avatars.githubusercontent.com/u/1627867?v=4)](https://github.com/Nebual "Nebual (1 commits)")[![Bilge](https://avatars.githubusercontent.com/u/470626?v=4)](https://github.com/Bilge "Bilge (1 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (1 commits)")[![jkuchar](https://avatars.githubusercontent.com/u/133822?v=4)](https://github.com/jkuchar "jkuchar (1 commits)")[![jules-iti](https://avatars.githubusercontent.com/u/36045067?v=4)](https://github.com/jules-iti "jules-iti (1 commits)")[![Mikulas](https://avatars.githubusercontent.com/u/192200?v=4)](https://github.com/Mikulas "Mikulas (1 commits)")[![belfie13](https://avatars.githubusercontent.com/u/39270867?v=4)](https://github.com/belfie13 "belfie13 (1 commits)")

---

Tags

polyfillphpdata structuresds

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpxmlrpc/polyfill-xmlrpc

A pure-php reimplementation of the API exposed by the native XML-RPC extension

12424.1k3](/packages/phpxmlrpc-polyfill-xmlrpc)[roxblnfk/unpoly

Remove unnecessary PHP polyfills

4135.8k18](/packages/roxblnfk-unpoly)[judev/php-intervaltree

Interval Tree implementation in PHP

1141.8k1](/packages/judev-php-intervaltree)[ducks-project/spl-types

Polyfill Module for SplType PHP extension. This extension aims at helping people making PHP a stronger typed language and can be a good alternative to scalar type hinting. It provides different typehandling classes as such as integer, float, bool, enum and string

1033.1k](/packages/ducks-project-spl-types)

PHPackages © 2026

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