Download the PHP package hassan/one-loop without Composer
On this page you can find all versions of the php package hassan/one-loop. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hassan/one-loop
More information about hassan/one-loop
Files in hassan/one-loop
Package one-loop
Short Description A Laravel/PHP Package for Minimizing Collection/Array Iterations
License MIT
Homepage https://github.com/dhassanali/one-loop
Informations about the package one-loop
One Loop
A Laravel/PHP Package for Minimizing Collection/Array Iterations - optimized for large datasets (100,000+ records).
๐ Performance Benchmarks
Real-world performance tests show significant improvements with large datasets:
| Dataset Size | Operations | Standard PHP | OneLoop | Improvement |
|---|---|---|---|---|
| 500,000 | Complex (3+ ops) | 163.03 ms | 105.84 ms | 35% faster โ |
| 500,000 | Simple (2 ops) | 226.32 ms | 161.79 ms | 29% faster โ |
| 100,000 | Complex (3+ ops) | 25.83 ms | 18.54 ms | 28% faster โ |
| 10,000 | Any | 0.98 ms | 1.84 ms | 88% slower โ ๏ธ |
| 1,000 | Any | 0.08 ms | 0.19 ms | 137% slower โ ๏ธ |
โ ๏ธ Performance Warning
This package is optimized for large datasets. It provides significant performance improvements when:
- Processing 100,000+ records
- Chaining 2-3+ operations (filter, map, reject, etc.)
- Running batch jobs or data processing tasks
For small datasets (< 50,000 records), standard PHP array functions or Laravel Collections will be faster due to lower overhead.
Installation
Install the package via composer:
Usage
Basic Example
๐ New Features in v2.0
Early Exit with limit() / take()
Stop processing once you have enough results:
Extract Properties with pluck()
Remove Duplicates with unique()
Group Items with groupBy()
Conditional Operations with when()
Laravel Collection Integration
OneLoop automatically integrates with Laravel Collections:
๐ Available Methods
Filtering
filter(callable $callback)- Keep items that match conditionreject(callable $callback)- Remove items that match condition
Transformation
map(callable $callback)- Transform each itempluck(string|callable $value)- Extract specific property
Uniqueness & Grouping
unique(?string|callable $key = null)- Remove duplicatesgroupBy(string|callable $groupBy)- Group by key or callback
Limiting
limit(int $limit)- Limit results (early exit)take(int $count)- Alias for limit()
Conditional
when(bool $condition, callable $callback, ?callable $default = null)- Conditional operations
Execution
apply()- Execute all queued operations and return results
๐ When to Use OneLoop
โ Perfect For:
- Large datasets (100K+ records)
- Batch processing jobs
- ETL operations
- Data migrations
- Complex filtering with 2-3+ operations
- Report generation
- Product catalog filtering (e-commerce)
- Customer segmentation (marketing)
โ Not Ideal For:
- Small datasets (< 50K records)
- Single operation (just one filter or map)
- Real-time web requests with small result sets
- When microseconds matter with tiny datasets
๐ฏ Real-World Example
๐งช Testing
๐ Changelog
Please see CHANGELOG for more information on what has changed recently.
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
๐ License
The MIT License (MIT). Please see License File for more information.
๐ Credits
- Hassan Ali
- All Contributors
All versions of one-loop with dependencies
illuminate/support Version ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/contracts Version ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0