Download the PHP package tiny-blocks/collection without Composer

On this page you can find all versions of the php package tiny-blocks/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

Collection

Overview

The Collection library provides a flexible and efficient API to manipulate, iterate, and manage collections in a structured and type-safe manner.

It leverages PHP's Generators for optimized memory usage and lazy evaluation, ensuring that large datasets are handled efficiently without loading all elements into memory at once.

The library supports adding, removing, filtering, sorting, and transforming elements.

Installation

How to use

The library exposes the available behaviors through the Collectible interface and provides utilities to manipulate collections of various types.

Concrete implementation

The Collection class implements the Collectible interface and provides a concrete implementation for handling collections.

It allows for adding, removing, filtering, and sorting elements, as well as transforming them into different formats like arrays and JSON.

The class is designed to work with generic key-value pairs, ensuring type safety and flexibility for a variety of use cases.

Writing

These methods enable adding, removing, and modifying elements in the Collection.

Adding elements

Removing elements

Filtering

These methods enable filtering elements in the Collection based on specific conditions.

Filter by predicate

Ordering

These methods enable sorting elements in the Collection based on the specified order and optional predicates.

Sort by order and custom predicate

Retrieving

These methods allow access to elements within the Collection, such as fetching the first or last element, counting the elements, or finding elements that match a specific condition.

Retrieve count

Retrieve by condition

Retrieve single elements

Retrieve collection elements

Comparing

These methods enable comparing collections to check for equality or to apply other comparison logic.

Check if collection contains element

Compare collections for equality

Aggregation

These methods perform operations that return a single value based on the Collection's content, such as summing or combining elements.

Transforming

These methods allow the Collection's elements to be transformed or converted into different formats.

Applying actions without modifying elements

Grouping elements

Mapping elements

Flattening elements

Convert to array

Convert to JSON

FAQ

01. Why is my iterator consumed after certain operations?

The Collection class leverages PHP's Generators to provide lazy evaluation, meaning elements are only generated as needed.

It cannot be reused once a generator is consumed (i.e., after you iterate over it or apply certain operations).

This behavior is intended to optimize memory usage and performance but can sometimes lead to confusion when reusing an iterator after operations like count, toJson, or toArray.

02. How does lazy evaluation affect memory usage in Collection?

Lazy evaluation, enabled by PHP's Generators, allows Collection to handle large datasets without loading all elements into memory at once.

This results in significant memory savings when working with large datasets or performing complex chained operations.

However, this also means that some operations will consume the generator, and you cannot access the elements unless you recreate the Collection.

License

Collection is licensed under MIT.

Contributing

Please follow the contributing guidelines to contribute to the project.


All versions of collection with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
tiny-blocks/serializer Version ^3
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 tiny-blocks/collection contains the following files

Loading the files please wait ....