PHPackages                             listem/listem-php - 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. [Search &amp; Filtering](/categories/search)
4. /
5. listem/listem-php

ActiveLibrary[Search &amp; Filtering](/categories/search)

listem/listem-php
=================

Listem is an easy to use (but highly customizable) data sorting and filtering module for PHP, that can be used for data lists/tables/grids, reports or APIs.

6302[6 issues](https://github.com/listem/listem-php/issues)[1 PRs](https://github.com/listem/listem-php/pulls)PHP

Since Jan 24Pushed 8y ago2 watchersCompare

[ Source](https://github.com/listem/listem-php)[ Packagist](https://packagist.org/packages/listem/listem-php)[ RSS](/packages/listem-listem-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (6)Used By (0)

Listem
======

[](#listem)

[![Build Status](https://camo.githubusercontent.com/9876b7a72b4b2196b66da8bb53b4cf8fc4985c1ee628975a24748c905f5503b2/68747470733a2f2f7472617669732d63692e6f72672f6c697374656d2f6c697374656d2d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/listem/listem-php)

Listem is an easy to use (but highly customizable) data sorting and filtering module for PHP &gt;= 5.4, which can be used for data lists/tables/grids, reports or APIs.

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

[](#installation)

Make sure you have [Composer installed](https://getcomposer.org/doc/00-intro.md#globally) and run the below command from your project directory.

```
composer require listem/listem-php
```

General Usage
-------------

[](#general-usage)

Set configurations and initialize.

```
$config = [
    'filters' => [
        'name' => ['label' => 'Title'],
        'content' => ['label' => 'Content', 'column' => ['content', 'summary']],
        'state' => [
            'label' => 'State',
            'type' => Listem\Filter::ENUM_INPUT,
            'enums' => [
                1 => 'Active',
                0 => 'Draft'
            ]
        ],
        'created_at' => ['label' => 'Created On', 'type' => Listem\Filter::DATE],
        'category' => ['label' => 'Category', 'type' => Listem\Filter::ENUM_SELECT]
    ],
    'sorters' => [
        'name' => ['label' => 'Full Name', 'column' => 'users.name'],
        'active' => ['label' => 'Active', 'column' => 'users.active']
    ]
];

$list = new Listem\ListEntity($config, new Listem\Conditions\MySQL, new Listem\Params\Get);

$filters = $list->getFilters();
$sorters = $list>getSorters();

$filterConditions = $filters->getConditions();

$sorterConditions = $sorters->getConditions();

$data = BlogPost::whereRaw($condition);
    ->orderBy($sorterConditions['column'], $sorterConditions['side'])
    ->get()
    ->toArray();
```

Pass `$filters` and `$sorters` to your view and render them easily.

```

            renderLabel() ?>
            renderFormElem() ?>

    Reset
    Filter

            render('title') ?>
            Slug
            render('content') ?>
