PHPackages                             kiwiz/ecl - 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. kiwiz/ecl

ActiveLibrary

kiwiz/ecl
=========

ECL

v1.0.0(7y ago)02.7k1PHPCI passing

Since Sep 29Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kiwiz/ecl)[ Packagist](https://packagist.org/packages/kiwiz/ecl)[ RSS](/packages/kiwiz-ecl/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (4)Versions (5)Used By (0)

ECL
===

[](#ecl)

[![Build Status](https://camo.githubusercontent.com/aea9c945d6a33db4d21c7d70cf8cc63d8b22e55f47c0c3b0fb6e051994c78d8c/68747470733a2f2f7472617669732d63692e6f72672f6b6977697a2f65636c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kiwiz/ecl) [![Code Climate](https://camo.githubusercontent.com/38a661b2274cdb6acae0e5c1a76c2b2c784bdadd7c5476d6f37c1597ddbd1489/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6b6977697a2f65636c2f6261646765732f6770612e737667)](https://codeclimate.com/github/kiwiz/ecl) [![Test Coverage](https://camo.githubusercontent.com/289fb4f068d5532dfd96cf1b94501b95483bfaa086abb1b7b906c672df04e53a/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6b6977697a2f65636c2f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/kiwiz/ecl/coverage)

ECL is a simple query language intended for use with data sources that generate tabulated data. It allows you to query data from these sources and do some limited manipulation. It supports conditional statements, loops, variables and comments. There are almost certainly bugs. Pls report!

Syntax
------

[](#syntax)

ECL is based on bash's shell syntax. You'll find similar ideas here:

- Comments (`# HACK`).
- Variables (bools, ints, floats, strings, arrays).
- String concatentation (`"app"'le'`).
- Output redirection via `>` and `|`.
- Control flow (`if` and `for`). And some other stuff I'm forgetting.

The authoritative source for syntax questions is the [grammar](https://github.com/kiwiz/ecl/blob/master/grammar.pegjs). For a gentler introduction, try checking out the examples below.

Example Programs
----------------

[](#example-programs)

```
set type="access_log"; # Define the type we want to query
es:logstash _type:$type > res_a; # Query ES for data and store the results into a variable
if `count(res_a) > 0` { # If we got results...
    # Load up our results and use it in a follow up query.
    # Look for any info_log documents that match any of the `request_uaid`s in our first result set.
    load res_a | es:logstash _type:info_log request_uaid:$_.request_uaid;
}

```

```
set list=["one","two","three"];
for list {
    es:logstash a:$_.value;
}

```

Reference
=========

[](#reference)

Comments
--------

[](#comments)

```
# This is a comment

```

Statements
----------

[](#statements)

### Set

[](#set)

`set VAR=VALUE`

The set statement allows you to assign a primitive value to a variable. Has no return value.

`VAR`: The name of the variable. `VALUE`: The value to set the variable to. Supports bools, ints, floats, strings and arrays.

Example: `set num=10`

### Cond

[](#cond)

```
if `COND` {
    BRANCH_A
}

```

```
if `COND` {
    BRANCH_A
} else {
    BRANCH_B
}

```

The if statement allows you to branch execution. It accepts an ECL expression which allows you to access any global variables. Returns the value of the winning branch.

`COND`: An SEL expression. `BRANCH_A`: The truthy branch. `BRANCH_B`: The falsey branch.

Example: `if `true` { es:logstash url:"/" } else { es:logstash -url:"/" }`

### Loop

[](#loop)

```
for VAR {
    CODE
}

```

The loop statement allows you to loop over a result. Each iteration of the loop body sets the `_` variable. Returns the value of the loop body.

`VAR`: The result to iterate over. `CODE`: The code block to execute.

Example: `for res { count }`

### CommandList

[](#commandlist)

```
AAA

```

```
AAA | BBB | ...

```

```
AAA | BBB | > VAR_A | CCC | DDD > VAR_B

```

The CommandList is a pipeline of Commands to execute. Output from each Command flows to the next one until it reaches the end. You can copy the output for almost all Commands into a varible. Returns the output from the final Command iff it is not redirected into a variable.

`AAA`,`BBB`,`CCC`,`DDD`: Commands

Commands
--------

[](#commands)

### Count

[](#count)

```
count

```

Returns the result count for the result set.

### Filter

[](#filter)

```
filter `EXPR`

```

Filters the result set with the provided expression.

`EXPR`: An SEL expression.

Example: `filter `\_\['level'\] == 'info'``

### Head

[](#head)

```
head NUM

```

Returns the first n results.

`NUM`: The max number of results to return.

Example: `head 5`

### Tail

[](#tail)

```
tail NUM

```

Returns the last n results.

`NUM`: The max number of results to return.

Example: `tail 5`

### Join

[](#join)

```
join:TYPE RES=FIELD+FIELD+...

```

Performs an inner join on two result sets.

`TYPE`: The type of join (`inner`, `left`, `right`). `RES`: The result set to join with. `FIELD`: The field to join on.

Example: `join res_a=request_uaid`

### Map

[](#map)

```
map -FIELD

```

```
map AAA+BBB=CCC

```

```
map FIELD=`EXPR`

```

```
map [AAA,BBB,CCC]

```

Map field names and values in the results. You can specify multiple clauses in a single Command and they'll be executed in order.

Example: `map count=`\_ + 3` _type=type -_type`

### Search

[](#search)

```
es:SRC QUERY

```

```
es:SRC OPTS QUERY | agg:ATYPE AFIELD AOPTS

```

Returns data from ES. Supports ES2.x-ES6.x

`SRC`: The source (usually `logstash`). `OPTS`: Search options. `QUERY`: A query. `ATYPE`: Aggregation type. `AOPTS`: Aggregation options.

Supports most standard ES syntax with a few extras:

Example: `es:logstash _type:info_log | agg:terms ip_addr`

### Sort

[](#sort)

```
sort FIELD,ORD ...

```

Returns the results, sorted.

`FIELD`: The field name to sort on. `ORD`: `asc` or `desc`.

Example: `sort request_time,asc`

### Load

[](#load)

```
load AAA

```

```
load AAA,BBB,...

```

Load a result set.

`AAA`,`BBB`: Variables.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Every ~769 days

Total

2

Last Release

2792d ago

Major Versions

v0.9.0 → v1.0.02018-11-07

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3122114?v=4)[Kai](/maintainers/kiwiz)[@kiwiz](https://github.com/kiwiz)

---

Top Contributors

[![kiwiz](https://avatars.githubusercontent.com/u/3122114?v=4)](https://github.com/kiwiz "kiwiz (40 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kiwiz-ecl/health.svg)

```
[![Health](https://phpackages.com/badges/kiwiz-ecl/health.svg)](https://phpackages.com/packages/kiwiz-ecl)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[unopim/unopim

UnoPim Laravel PIM

10.5k2.2k](/packages/unopim-unopim)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k8.7k1](/packages/kimai-kimai)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

84735.1k](/packages/flow-php-flow)[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

54642.4k4](/packages/jolicode-castor)

PHPackages © 2026

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