Download the PHP package saintropeworks/php-linq without Composer
On this page you can find all versions of the php package saintropeworks/php-linq. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download saintropeworks/php-linq
More information about saintropeworks/php-linq
Files in saintropeworks/php-linq
Package php-linq
Short Description A PHP implementation of LINQ-style enumerable operations.
License MIT
Informations about the package php-linq
PHP LINQ
A modern PHP implementation of Microsoft's LINQ (Language Integrated Query), designed specifically for PHP 8.5+ and optimized for composable, pipeline-based query construction.
PHP LINQ is intended to provide a familiar LINQ programming model to PHP developers while taking advantage of modern PHP language features rather than attempting to maintain compatibility with legacy PHP versions.
Requirements
- PHP 8.5 or later
- Composer
PHP LINQ is intentionally not designed for backwards compatibility with older PHP versions. The library targets modern PHP and makes use of language features available in PHP 8.5+, including the pipeline operator (|>).
Installation
Install PHP LINQ through Composer:
Example
LINQ Functions
LINQ functions are imported using PHP's use function syntax, allowing you to pull in only the operations you want to use:
The goal is to provide the full C# LINQ operation set in PHP. Where PHP's lack of method overloading makes a direct one-to-one translation impossible, separate function names are used to represent the different overloads.
For example:
Where— The standardFunc<TSource, bool>predicate.WhereWithIndex— The overload usingFunc<TSource, int, bool>.
This same approach is used throughout the library where necessary to preserve the functionality of the corresponding LINQ overloads.
How It Works
All of the functions exposed through SRW\LINQ are essentially partial-function wrappers around the corresponding functions provided by Enumerable.
There is nothing stopping you from using Enumerable directly:
However, the point of the function wrappers is to get as close as PHP can reasonably get to the fluent, extension-method style of C# LINQ.
Combined with PHP's pipeline operator (|>), the result is a composable LINQ-style query syntax:
The goal is simple: make LINQ feel like LINQ, while working with PHP rather than fighting against it.