Comparing PHP Collections

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • php-generics

    PHP generics written in PHP

    If you are only using simple collections you can use array - it is very fast and requires little memory. PHP doesn't support generic syntax and IDE can't make hints about the type of objects in a collection (yet), but if you want PHP to do type checks at runtime you can test the php-generics library.

  • php-var-sizeof

    Function for getting size of any PHP variable in bytes

    Memory test is very simple. It creates $collection and puts Item objects into it count times. For measurement I use var_sizeof() and memory_get_usage().

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

  • PHPBench

    PHP Benchmarking framework

    I used phpbench to measure performance. I think one of the big differences between all the solutions is the type checking. So I decided to try measure it. How much faster will code with/without type checking?

  • php-collections-comparison

    If you want to reproduce the tests result you can find the source code and instructions here.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts