Download the PHP package nmarniesse/phindexer without Composer
On this page you can find all versions of the php package nmarniesse/phindexer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package phindexer
Phindexer
PHP data indexer that speeds up your data operations.
When you need to filter or search item from a collection, the operation could take time and effort to retrieve your data. And unless you index your data manually (with a hash strategy for example) the operation could slow down your program drastically.
This projects helps you to index your data and retrieve them simply and quickly.
Requirements
- php 7.1
- ext-json
Install
Performances
Here is some tests to check the performance. First we create a collection of 10,000 items then we launch
1000 searches on it.
The PhindexerJob
uses this lib to index the items, the ClassicJob
do not index and iterates on items on each
searches. The results vary depending on the computer.
Documentation
Index and search on a collection
Using custom index
Maybe you want index your data with more complex condition. You can pass the function you want with
ExpressionIndex
:
Using collection of objects
The Collection
class can also contains a set of objects. You can even mix objects and associative arrays.
When you index by key, the system tries to index the property. It can be a public properties or protected/private
property if the getter function is available.
Add items in a collection
Once the collection is initialize, you can add items in it. You can even create an empty collection in one hand and add items in other hand. Added items are indexed the same way.
Here is an example with Collection
, the same behavior exists with Collection
:
Validation constraint
If you need to ensure the items have always the good structure, or the same type, you can specified some constraints
in your collection.
The validation is checked on each items when the collection is instantiated, and on each item you add further.
All versions of phindexer with dependencies
ext-json Version *
psr/log Version ~1.0
ramsey/uuid Version ^3.8
symfony/validator Version ^4.2
doctrine/inflector Version ^1.3