A PHP library inspired by the LINQ 2 Objects extension methods in .NET.
For a full introduction read my blog post.
LINQ queries offer three main advantages over traditional foreach loops:
They are more concise and readable, especially when filtering multiple conditions.
They provide powerful filtering, ordering, and grouping capabilities with a minimum of application code.
In general, the more complex the operation you want to perform on the data, the more benefit you will realize by using LINQ instead of traditional iteration techniques.
fusonic/linq is supported on PHP 5.3 and up.
The most flexible installation method is using Composer: Simply create a composer.json file in the root of your project:
{
"require": {
"fusonic/linq": "@dev"
}
}
Install composer and run install command:
curl -s http://getcomposer.org/installer | php
php composer.phar install
Once installed, include vendor/autoload.php in your script to autoload fusonic/linq.
require 'vendor/autoload.php';
use Fusonic\Linq\Linq;
Linq::from(array())->count();
You can run the test suite with the following command:
phpunit --bootstrap tests/bootstrap.php .
This library is licensed under the MIT license.