No description
  • PHP 51.4%
  • C 47.7%
  • M4 0.5%
  • JavaScript 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Rudi Theunissen d4cb6c3c1f ci: add Arch Linux PHPT job
Tests against Arch's rolling-release PHP package to catch issues
with the latest system libraries and compiler versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 16:45:17 -05:00
.github/workflows ci: add Arch Linux PHPT job 2026-04-14 16:45:17 -05:00
src v2.0.0 — Redesign extension for new type system 2026-04-11 19:08:11 -07:00
tests v2.0.0 — Redesign extension for new type system 2026-04-11 19:08:11 -07:00
.editorconfig Add editorconfig 2016-02-21 13:52:36 +13:00
.gitignore Add basic local development scripts 2023-12-18 11:03:13 +01:00
.valgrindrc Update .valgrindrc 2017-08-05 02:16:50 +12:00
CHANGELOG.md v2.0.0 — Redesign extension for new type system 2026-04-11 19:08:11 -07:00
composer.json v2.0.0 — Redesign extension for new type system 2026-04-11 19:08:11 -07:00
config.m4 v2.0.0 — Redesign extension for new type system 2026-04-11 19:08:11 -07:00
config.w32 ci: replace AppVeyor with GitHub Actions for Windows 2026-04-12 10:05:37 +02:00
CONTRIBUTING.md Update CONTRIBUTING.md example PHP version 2026-04-10 18:28:13 -07:00
dev.sh Add basic local development scripts 2023-12-18 11:03:13 +01:00
docker-compose.yml Add basic local development scripts 2023-12-18 11:03:13 +01:00
Dockerfile chore: use php 8.5 in Dockerfile 2026-03-01 16:50:22 +01:00
Dockerfile.alpine ci: run PHPT tests in Docker with debian/alpine matrix 2026-04-14 16:41:22 -05:00
Dockerfile.arch ci: add Arch Linux PHPT job 2026-04-14 16:45:17 -05:00
Dockerfile.debian ci: run PHPT tests in Docker with debian/alpine matrix 2026-04-14 16:41:22 -05:00
ext-ds.ini Add basic local development scripts 2023-12-18 11:03:13 +01:00
LICENSE 1.1.3 2016-08-08 13:55:45 +12:00
package.xml v2.0.0 — Redesign extension for new type system 2026-04-11 19:08:11 -07:00
php_ds.c v2.0.0 — Redesign extension for new type system 2026-04-11 19:08:11 -07:00
php_ds.h v2.0.0 — Redesign extension for new type system 2026-04-11 19:08:11 -07:00
phpunit.xml Release 1.6.0 — PHP 8.2+, serialization, and bug fixes 2026-04-10 16:36:19 -07:00
README.md ci: replace AppVeyor with GitHub Actions for Windows 2026-04-12 10:05:37 +02:00
sandbox.php Fix ds_vector_map using bad capacity 2020-09-02 19:09:11 -07:00
test.php Release 1.6.0 — PHP 8.2+, serialization, and bug fixes 2026-04-10 16:36:19 -07:00

Native Data Structures for PHP

Build Status PECL

A PHP language extension that provides specialized data structures as efficient alternatives to the PHP array.

v2.0 introduces a simplified API with fewer types and copy-on-write (COW) semantics for safe iteration during mutation. The core types are Seq, Map, Set, Heap, Pair, and Key.

You can read about the original motivation for this project in this blog post.

Documentation

Documentation is available on php.net. Note that the php.net docs may not yet reflect the v2.0 changes. The v2.0 types are:

  • Ds\Seq -- unified sequence (replaces Vector, Deque, Stack, and Queue)
  • Ds\Map -- ordered dictionary with support for arbitrary keys
  • Ds\Set -- ordered set of unique values
  • Ds\Heap -- configurable heap with optional comparator (replaces PriorityQueue)
  • Ds\Pair -- readonly key-value pair
  • Ds\Key -- interface for custom key equality (replaces Hashable)

You should also include the polyfill in your project for IDE integration.

Installation

Requires PHP >= 8.2.

The easiest way to install the extension is to use PECL:

pecl install ds

If you're on Windows, you can download a compiled .dll on PECL or under releases.

Enabling the extension

You'll need to add extension=ds.so to your primary php.ini file.

If you encounter an "undefined symbol" error, see #2.

# To see where .ini files are located
php -i | grep "\.ini"

You can also enable the extension temporarily using the command line:

php -d extension=ds.so

Note: Windows would use php_ds.dll instead.

Testing

Tests are split between PHPT tests and PHPUnit shared tests.

# PHPT tests (native extension tests)
make test

# PHPUnit shared tests (requires Composer)
composer install
composer test

Compatibility

You may include the polyfill as a dependency in your project. This allows your codebase to still function in an environment where the extension is not installed.

Contributing

For local development, I'm using Docker:

./dev.sh  # opens a shell into a development environment

phpize
./configure
make
make install

composer install
composer test

Please see CONTRIBUTING for more information.

Credits

License

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