Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkloubert/phpLINQ
LINQ concept for PHP
https://github.com/mkloubert/phpLINQ
Last synced: about 2 months ago
JSON representation
LINQ concept for PHP
- Host: GitHub
- URL: https://github.com/mkloubert/phpLINQ
- Owner: mkloubert
- License: bsd-3-clause
- Created: 2015-01-24T07:42:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-10-30T05:38:15.000Z (over 5 years ago)
- Last Synced: 2024-04-13T16:25:58.544Z (10 months ago)
- Language: PHP
- Size: 1.69 MB
- Stars: 40
- Watchers: 4
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-gitfather - phpLINQ
README
# phpLINQ
A [LINQ](https://en.wikipedia.org/wiki/Language_Integrated_Query) concept for [PHP](https://en.wikipedia.org/wiki/PHP).
Most methods are chainable as in [.NET](https://en.wikipedia.org/wiki/.NET_Framework) context.
Here you can find the [DOCUMENTATION](https://github.com/mkloubert/phpLINQ/wiki) in the wiki or the [API](http://phplinq.marcel-kloubert.eu/api/) documentation.
## Features
* [Lambda expressions](https://github.com/mkloubert/phpLINQ/wiki/Lambda-expression)
* Any kind of [lists or iterators](https://github.com/mkloubert/phpLINQ/wiki/Sequence) can be used
* Most methods are chainable as in [.NET](https://en.wikipedia.org/wiki/.NET_Framework) context
* Enhancements / improvements for use in PHP context## Requirements
* PHP 5.3+ ([branch v2](https://github.com/mkloubert/phpLINQ/tree/v2) or [branch v1](https://github.com/mkloubert/phpLINQ/tree/v1))
* PHP 7+ (master branch)## Example
A complete list can be found at the [live example page](https://github.com/mkloubert/phpLINQ/tree/master/examples).
```php
use \System\Linq;$seq = Enumerable::fromValues(5979, 23979, null, 23979, 1781, 241279);
$newSeq = $seq->select('$x => (string)$x') // transform all values
// to string
->where('$x => !empty($x)') // filter out all values that are empty
->skip(1) // skip the first element ('5979')
->take(3) // take the next 3 elements from current position
// ('23979', '23979' and '1781')
->distinct() // remove duplicates
->order(); // sort
foreach ($newSeq as $item) {
// [0] '1781'
// [1] '23979'
}
```## What you need
* The [phpLINQ.php](https://github.com/mkloubert/phpLINQ/blob/master/phpLINQ.php) file
* The whole [System](https://github.com/mkloubert/phpLINQ/tree/master/System) folderThe file / directory structure:
```
System/
phpLINQ.php
```## Implemented
* [aggregate()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.aggregate()-method)
* [all()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.all()-method)
* [any()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.any()-method)
* [average()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.average()-method)
* [cast()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.cast()-method)
* [concat()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.concat()-method)
* [contains()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.contains()-method)
* [count()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.count()-method)
* [defaultIfEmpty()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.defaultIfEmpty()-method)
* [distinct()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.distinct()-method)
* [elementAt()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.elementAt()-method)
* [elementAtOrDefault()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.elementAtOrDefault()-method)
* [except()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.except()-method)
* [first()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.first()-method)
* [firstOrDefault()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.firstOrDefault()-method)
* [groupBy()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.groupBy()-method)
* [groupJoin()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.groupJoin()-method)
* [intersect()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.intersect()-method)
* [join()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.join()-method)
* [last()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.last()-method)
* [lastOrDefault()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.lastOrDefault()-method)
* [max()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.max()-method)
* [min()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.min()-method)
* [ofType()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.ofType()-method)
* [orderBy()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.orderBy()-method)
* [orderByDescending()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.orderByDescending()-method)
* [reverse()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.reverse()-method)
* [select()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.select()-method)
* [selectMany()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.selectMany()-method)
* [sequenceEqual()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.sequenceEqual()-method)
* [single()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.single()-method)
* [singleOrDefault()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.singleOrDefault()-method)
* [skip()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.skip()-method)
* [skipWhile()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.skipWhile()-method)
* [sum()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.sum()-method)
* [take()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.take()-method)
* [takeWhile()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.takeWhile()-method)
* [toArray()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.toArray()-method)
* [toDictionary()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.toDictionary()-method)
* [toList()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.toList()-method)
* [toLookup()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.toLookup()-method)
* [union()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.union()-method)
* [where()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.where()-method)
* [zip()](https://github.com/mkloubert/phpLINQ/wiki/IEnumerable.zip()-method)