Cartalyst LLC.
Collections by Cartalyst
1
14
0
12
73

Preface

Introduction

A Collections Abstraction library for PHP

The Collection library is one of the most useful things that many modern languages has, but for some reason PHP doesn't has a built in collection layer.

The package requires PHP 5.4+ and follows the FIG standards PSR-1, PSR-2 and PSR-4 to ensure a high level of interoperability between shared PHP code and is fully unit-tested.

Have a read through the Installation Guide.

Examples

Instantiate a new Collection
$collection = new Cartalyst\Collections\Collection([
    'item1' => 'Item 1',
    'item2' => 'Item 2',
]);
Get how many items are inside a Collection
echo $collection->count();
// > 2
Retrieve an item inside of the Collection
echo $collection->item1;
// Item 1

Setup

Installation

The best and easiest way to install the Collections package is with Composer.

Preparation

Open your composer.json file and add the following to the require array:

"cartalyst/collections": "^1.0"

Note: Make sure that after the required changes your composer.json file is valid by running composer validate.

Install the dependencies

Run Composer to install or update the new requirement.

php composer install

or

php composer update

Now you are able to require the vendor/autoload.php file to autoload the package.

Usage

In this section we'll show how to use the Collection class.

You wont find fancy lifestyle graphics and marketing bravado here. Just cold... hard... code...

Code Well, Rock On!
Processing Payment...