Download the PHP package fschaechter/php-collection without Composer

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

PHP-Collection

PHP-Collection is an easy to use library for handling sets of data with support for filtering, sorting and reducing the data sets.

The class Collection extends PHP's ArrayObject and so brings a little extra to the table.

Build Status

Installation

You can just clone the repository and use it as you see fit or use Composer and handle the dependency management very efficiently.

Composer

Append the following line to the require-key of your composer.json file.

"fschaechter/php-collection": "~2"

Issues and bugs

You can report bugs, problems and other issues here. Every useful bit is very much appreciated.

Tutorial

First you need a some data and create a collection.

<?php
$data = array(
    "Apple",
    "Apple,"
    "Pear",
    "Been",
    "Pear",
    "Strawberry",
);
$collection = new \Collection\Collection($data);

Append some more data.

<?php
$collection->append("Been");
$collection[] = "Pear";

Now you can just iterate over the data.

<?php
echo sprinft(
    "We have %s items." . PHP_EOL,
    count($collection)
);

foreach ($collection as $item) {
    echo $item . PHP_EOL;
}

It would be nice if the collection is sorted.

<?php
$comparator = new \Collection\Comparator\String();
$sorter = new \Collection\Sorter\Uasort($comparator);
$collection->sort($sorter);

foreach ($collection as $item) {
    echo $item . PHP_EOL;
}

We don't like apples.

<?php
$filter = new \Collection\Filter\Unequal("Apple");
$collection = $collection->filter($filter);

foreach ($collection as $item) {
    echo $item . PHP_EOL;
}

Let's distill the items.

<?php
$reducer = new \Collection\Reducer\Distinct();
$collection = $collection->reduce($reducer);

foreach ($collection as $item) {
    echo $item . PHP_EOL;
}

More examples

Take a look at the examples directory, there you will find three example of how to play with a collection.

Quality?

This library is developed under the principles of TDD. You can find all the tests within the tests directory. Check for yourself using PHPUnit.

$ bin/phpunit

Apache Ant is used for the complete build process. See build.xml, the file is based on the one you can find in PHPUnit's github.com repo.

$ ant

And Travis-CI makes sure its tested over and over again.

Tips and tricks

Enhance the PATH

All commands are installed to the bin directory by Composer. Add this directory to the environment path and there are easy accessible.

Here's an example for BASH, add the line to the ~/.bashrc.

PATH="./bin:$PATH"

Now it is very simple to run the unit tests.

$ phpunit

Instead of

$ bin/phpunit

So much more productivity gained.

Why?

I come across a lot of data in form of list almost daily and i need an easy, testable and pragmatic way to extract information of these lists.

License

This library is licensed under the terms of the GNU General Public License v3.

Whats new?

2.3.1 Updated documention.

Added Travis CI status image. Updated documentation.

2.3.0 Exceptions and a new filter.

Added exception classes. Added a new filter for simple filtering of arrays.

2.2.0 Enhanced collection.

Added isEmpty() to Collection, so you can check if the collection is empty or has some elements.

2.1.0 Enhanced collection.

Added method getFirst() to Collection. This makes it easier to access the first element of the collection.

2.0.1 Fixed example.

There was a bug in examples/example_sort.php.

2.0.0 Refactored comparators.

The comparators moved from the namespace \Collection\Sorter\Comparator to \Collection\Comparator. This changed the API incompatibly with the prior version 1.0.0.

1.0.0 Started library.

This is the initial project.


All versions of php-collection with dependencies

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

Loading the files please wait ....