PHPackages                             devgroup/yii2-data-structure-tools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. devgroup/yii2-data-structure-tools

ActiveYii2-extension[Caching](/categories/caching)

devgroup/yii2-data-structure-tools
==================================

Data structure collections, helpers and utilities for yii2 ActiveRecord models(trees, sorts and etc.)

0.1(9y ago)79953[5 issues](https://github.com/DevGroup-ru/yii2-data-structure-tools/issues)1MITPHPPHP &gt;=5.5.0

Since May 19Pushed 9y ago7 watchersCompare

[ Source](https://github.com/DevGroup-ru/yii2-data-structure-tools)[ Packagist](https://packagist.org/packages/devgroup/yii2-data-structure-tools)[ RSS](/packages/devgroup-yii2-data-structure-tools/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (3)Used By (1)

Yii2 data structures tools
==========================

[](#yii2-data-structures-tools)

TBD

**WARNING:** This extension is under active development. Don't use it in production!

[![Build Status](https://camo.githubusercontent.com/8d4b18c13192aa139f0ccf53a4da5d5656d8bcb57f6b3179b09a7ea90d156a00/68747470733a2f2f7472617669732d63692e6f72672f44657647726f75702d72752f796969322d646174612d7374727563747572652d746f6f6c732e737667)](https://travis-ci.org/DevGroup-ru/yii2-data-structure-tools)[![codecov.io](https://camo.githubusercontent.com/df178888d17e736e6d895183aa31f2ccdf78373f5a2a75cd8f3d9dbf1828d14b/68747470733a2f2f636f6465636f762e696f2f6769746875622f44657647726f75702d72752f796969322d646174612d7374727563747572652d746f6f6c732f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/DevGroup-ru/yii2-data-structure-tools?branch=master)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist devgroup/yii2-data-structure-tools "*"

```

or add

```
"devgroup/yii2-data-structure-tools": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

TBD

Credits and inspiration sources
-------------------------------

[](#credits-and-inspiration-sources)

Search concept
--------------

[](#search-concept)

*for now it works only with STATIC VALUES property storage*

*Note, that search will work only with models with `DevGroup\DataStructure\traits\PropertiesTrait` trait and `DevGroup\DataStructure\behaviors\HasProperties` behavior connected. See [how to connect (Russian for now)](/docs/ru/how-to-use.md)*

Extension provides flexible system of search. Each property have configuration point that switches ability to use this property in search.

Basic search will be done in two ways:

- common search against regular databases e.g.: `mysql`, `mariadb` etc;
- elasticsearch indices search.

Main feature is that if you want to use elasticseatch, and defined it in the app config, but not still configure it your search will just work fine with auto fallback to simple mysql searching. And when your elasticsearch will be properly started search will be automatically switched for elasticseatch.

Preferred search mechanism you can define in the application configuration files, like this:

```
    'modules' => [
    ...
         'properties' => [
             'class' => 'DevGroup\DataStructure\Properties\Module',
             'searchClass' => \DevGroup\DataStructure\searchOld\elastic\Search::class,
             'searchConfig' => [
                 'hosts' => ['host1:9200', 'https://host2:9200'],
                 'watcherClass' => MyWatch::class,
             ]

         ],
    ...
    ],

```

- `searchClass` - class to be used for search. If omit - there will be no search configured,
- `searchConfig` - array additional parameters to be applied for search object, except common search. For elastic search following special keys may be set:
    - `hosts` see [hosts config](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_configuration.html),
    - `watcherClass` - you can use your own watcher for elsticsearch if needed.

If you want to start using elasticsearch, first of all you have to [install and configure it](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html).

Then, if you already have entries in your database you may want to generate and load start indices. For this run in console:

```
./yii properties/elastic/fill-index

```

This command will create indices for all properties that you allowed to search.

How to search
=============

[](#how-to-search)

*For now only available to perform filtering against properties static values*

At any place you want
---------------------

[](#at-any-place-you-want)

```

```

This will render basic filter form with all properties and values contained in the elasticsearch index

- `'modelClass'` - required param, any model class name you have in your app with assigned properties and their static values,
- `'filterRoute'` - required param, `action` attribute for rendered filter form,
- `'config'` - optional, additional array of config. Special key `storage` will be used for definition against what property storage search will be proceed. If you omit it search will be work only against `StaticValues` storage by default

In your controller
------------------

[](#in-your-controller)

```
public function actionFilter()
{
  /** @var AbstractSearch $component */
  $search = \Yii::$app->getModule('properties')->getSearch();
  $config = ['storage' => [
      EAV::class,
      StaticValues::class,
    ]
  ];
  $modelIds = $search->filterByProperties(Page::class, $config, \Yii::$app->request->get('filter'));
  $dataProvider = new ActiveDataProvider([
      //provider config
  ]);
  //other stuff here
}

```

- `Page` - any model class name you have in your app with assigned properties and their static values
- `$modelIds` will contain all found model ids, according to selected property values in filter. Using them you can show anything you want,
- `'$config'` - optional, additional array of config. Special key `storage` will be used for definition against what property storage search will be proceed. If you omit it search will be work only against `StaticValues` storage by default

Filtering logic
---------------

[](#filtering-logic)

Filters uses both intersection and union operations while search.

Lets see, for example you have filter request like this:

```
[
    1 => [2,3],
    13 => [18,9,34]
]

```

First of all this means that we want to find products that has property values assigned with id 2,3 from property with id 1, and 18, 9, 34 from property with id 13.

*What will filter do?*

- For now it will find all products with assigned values with ids IN(2,3);
- then it will find all products with assigned values with ids IN(12,9,34);
- and finally it will return to you result of intersection from both previous results.

How to extend and implement
---------------------------

[](#how-to-extend-and-implement)

For all `Search` and `Watch` mechanisms you can use your custom implementation.

Actually you can create and use your own database connection, e.g.: `MongoDB`, `ArangoDB`.

Or you can just use your custom `Watch` class for elasticsearch index actualization.

Both `Search` and `Watch` classes are implements according interfaces and extends abstract classes

- `DevGroup\DataStructure\search\interfaces\Search` and `DevGroup\DataStructure\search\base\AbstractSearch` for `Search`
- `DevGroup\DataStructure\search\interfaces\Watch` and `DevGroup\DataStructure\search\base\AbstractWatch` for `Watch`

Just extend your class from needed abstract class and define it in application config, like described upper.

If you are realizing custom index, you probably need to create own controller for first time index initialization, like `DevGroup\DataStructure\commands\ElasticIndexController`

Define your own `Watch` class in your own `Search` class if necessary.

Clearly created and defined `Watch` class will be automatically subscribed to according system events.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance6

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3643d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19c9303caa5846f2500a35018dcbd3c7f07c74e30efc1bbf7878d54157ab9c4f?d=identicon)[bethrezen](/maintainers/bethrezen)

![](https://www.gravatar.com/avatar/b39988f8d3bfe24528079c8e623dfcf53bb2e44052866965a8a9347b0781aea0?d=identicon)[fps01](/maintainers/fps01)

---

Top Contributors

[![fps01](https://avatars.githubusercontent.com/u/2114997?v=4)](https://github.com/fps01 "fps01 (68 commits)")[![bethrezen](https://avatars.githubusercontent.com/u/260284?v=4)](https://github.com/bethrezen "bethrezen (49 commits)")[![Hector68](https://avatars.githubusercontent.com/u/920564?v=4)](https://github.com/Hector68 "Hector68 (48 commits)")[![iVovolk](https://avatars.githubusercontent.com/u/7910672?v=4)](https://github.com/iVovolk "iVovolk (1 commits)")[![lixey](https://avatars.githubusercontent.com/u/2060480?v=4)](https://github.com/lixey "lixey (1 commits)")

---

Tags

cachesortablesorttreeyii2extension

### Embed Badge

![Health badge](/badges/devgroup-yii2-data-structure-tools/health.svg)

```
[![Health](https://phpackages.com/badges/devgroup-yii2-data-structure-tools/health.svg)](https://phpackages.com/packages/devgroup-yii2-data-structure-tools)
```

###  Alternatives

[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k46](/packages/skeeks-cms)[undefinedor/yii2-cached-active-record

The cached activeRecord for the Yii2 framework

102.6k](/packages/undefinedor-yii2-cached-active-record)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
