Download the PHP package noctud/collection without Composer

On this page you can find all versions of the php package noctud/collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package collection

Noctud Collection

Docs codecov Latest Stable Version License: MIT Discord

Type-safe, mutable/immutable, sortable and key-preserving List/Map/Set collections for PHP 8.4+.

✨ Features

πŸ—ΊοΈ Architecture

Full architecture is shown in docs, there are also Writable interfaces for easy third party implementations.

πŸ—οΈ Constructing

Use factory functions from namespace Noctud\Collection.

Use stringMapOf/mutableStringMapOf and intMapOf/mutableIntMapOf for better performance and ~50% less memory β€” they use single-array storage and enforce key types at runtime.

πŸ“– Accessing

Array access is strict by default β€” throws on missing keys/indices. Use ?? for safe fallback.

Sets support only the contains method, they have no array access by design.

πŸŒͺ️ Filtering & transformations

All transformation methods (filter, map, flatMap, zip, partition, ...) always return a new immutable collection, regardless of whether the source is mutable or immutable. Unlike array_filter, Lists are always reindexed β€” no gaps, no need for array_values().

πŸ“Š Sorting

Every Collection and Map is sequentially ordered, so sorting is supported everywhere.

πŸ‘οΈ Map views

Every Map exposes live read-only $keys, $values, and $entries views. These are real Set and Collection objects backed by the same underlying store β€” mutations to the map are immediately visible through views and vice versa.

βœ”οΈ Quantifiers

Check if all/any or none of the elements match the predicate.

➰ Iterating

All collections are traversable.

⛓️ Chainable

Mutating methods return $this (Mutable) or a new instance (Immutable). Both share the same API, but immutable methods are marked with #[NoDiscard] to prevent accidental misuse.

Method tracked() wraps a mutable collection in a proxy that tracks changes. The $changed flag is available on the return value of each mutation method, not on the wrapper itself.

πŸ›‘οΈ Type safety

Mutable collections enforce strict typing β€” PHPStan warns if you try to add elements of incompatible types. Immutable collections allow type widening since they return a new instance with potentially different types.

πŸ”‘ Preserving key types

Map will always preserve original keys, you have to only worry about constructing the map.

πŸ’€ Lazy Initialization

Construct from a closure β€” the callback executes only on first access. Under the hood, lazy collections use PHP 8.4's Lazy Objects β€” the internal store is a ghost proxy materialized only when first accessed.

Lazy collections behave identically to eager ones β€” there is no way to tell from outside. Always construct lazy collections using closures, not Generator objects directly.

γŠ™οΈ Objects as keys

Use objects as map keys out of the box. By default, objects are hashed using spl_object_id.

Implement Hashable for custom identity semantics:

🧩 Extending

Every type you interact with is an interface β€” ImmutableList, MutableMap, Set, even MapEntry. Logic is encapsulated in traits, so you can turn any class into a collection.

For custom stores, database-backed collections, and more, see the Extending guide.

πŸš€ Performance

This library prioritizes type safety and correctness. Lists and Sets have minimal overhead compared to native arrays. The generic mapOf() uses dual-array storage to preserve any key type, which adds memory and performance overhead.

When keys are exclusively strings or integers, use the optimized variants for maximum performance:

These use single-array storage, skip key hashing entirely, and use ~50% less memory than mapOf().

Converting between mutable and immutable via toMutable()/toImmutable() uses copy-on-write β€” the data is shared until either side is modified, making variant switching virtually free.

πŸ”Ž Static analysis

Generics are fully supported by PHPStan and Psalm. PhpStorm has known limitations with generics inference.

πŸ“š Documentation


All versions of collection with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package noctud/collection contains the following files

Loading the files please wait ...