Download the PHP package bonami/collections without Composer

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

Collections for PHP with focus on Immutability and Functional Programming

Build Status Latest Stable Version License

Table of contents

Motivation

Why yet another collections library for PHP? Native PHP arrays or SPL structures like SplFixedArray or SplObjectStorage(and other) are mutable and has very strange interfaces and behaviors. They often represent more data structures at once (eg. SplObjectStorage represents both Set and Map) and theirs interfaces are designed for classic imperative approach.

We tried to design interfaces of our structures to be focused on declarative approach leveraging functional programing. For more safety, we designed structures to be immutable (we have some mutables as well, because sometime it is necessary for performance reasons)

All the code is designed to be type safe with phpstan generics.

Show me the code!

A code example is worth a thousand words, so here are some simple examples:

Filtering Person DTOs and extracting some information

Generating combinations

Generating combinations with lift

Character frequency analysis

Features

Structures

Type safety

We are using phpstan annotations for better type safety, utilizing generics. For even better type resolving, we created optional dependency phpstan-collections, which we strongly suggest installing if you use phpstan. It fixes some type resolving, especially for late static binding.

Traverse

You may find yourself in situation, where you map list using mapper function which returns values wrapped in Option but you'd rather have values unwrapped. And that is when traverse method comes handy:

Compare the result with usage of our old buddy ArrayList::map:

Did you spot the difference? We have list of options with strings inside here whereas we have option of list with strings inside in the first code example.

So traverse allows us to convert list of Options to Option of list with unwrapped values. And guess what - as usual, None will ruin everything:

Usage of traverse method is not limited to Option class. It will work with any applicative, so it is available for TrySafe, ArrayList & LazyList (Failure & empty list instances behave the same way as None).

License

This package is released under the MIT license.

Contributing

If you wish to contribute to the project, please read the CONTRIBUTING notes.


All versions of collections with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3|^8.0
ext-json Version *
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 bonami/collections contains the following files

Loading the files please wait ....