Download the PHP package originphp/collection without Composer

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

license build coverage

You can create a Collection using arrays or an object which is an instance of Traversable.

Installation

To install this package

Creating a Collection

To create a collection:

There is also a helper function which you can use.

Collections

After you have finished manipulating the data you can use toArray or toList to convert the collection. Some methods return a boolean (e.g. every) or number (e.g median, average etc.), however most will return a new collection, which then can be chained through other methods.

Iteration Methods

Extract

Extracts a single column from a collection to create a list. You can use dot notation.

You can also use a callback function :

Each

Go through each item of the collection. You should note that each does not modify data. If you want to modify data then use map.

Map

This will iterate through each item in the collection and pass value through a callback which can modify the data and return it, creating a new collection in the process.

Combine

Creates a new collection using keys and values.

Results from combine can also be grouped by a third key.

Chunk

Chunks a collection into multiple parts

Filter Methods

Filter

Filters results using a callback function

Reject

This is the inverse of filter.

Every

Run truth tests on every item in the collection.

Some

Check to see if at least one item matches the filter

Sorting

SortBy

Sorts a collection by a field or callback. To sort by a field, and you can use dot notation.

To sort by a callback.

The sortBy method accepts 3 arguments, with the first argument being the path or a callback.

The second argument is the direction,which can be either SORT_DESC or SORT_ASC.

The third argument depends upon the data and the same flags used by PHP Sort, which include:

Aggregation

Min

Gets the first item with the smallest value.

To sort by a callback.

Max

Gets the first item with the smallest value.

To sort by a callback.

Counting

SumOf

Gets the sum from a field or callback.

To get the sum using a callback

Avg

Gets the average value from a field or callback.

To get the average value using a callback

Median

Gets the median value from a field or callback.

To get the median value using a callback

Count

This a function to count items in the collection, it is useful when working with other collection methods such as take or chunk.

CountBy

Counts by a field and value, and results are grouped.

You can also use a callback.

Grouping

GroupBy

Groups results by a field or callback.

You can also use a callback.

Inserting Data

Insert

Inserts a value into a path for each item in the collection.

Taking the same example, I will chain it using the helper function. This can be done with any method that returns a new collection.

Other

Take

Take a number of items from a collection.


All versions of collection with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3.0
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 originphp/collection contains the following files

Loading the files please wait ....