PHPackages                             murzid/codeigniter-datatables - 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. murzid/codeigniter-datatables

ActiveLibrary

murzid/codeigniter-datatables
=============================

DataTables server-side for CodeIgniter

v1.0.2(2y ago)114MITPHPPHP &gt;=5.6

Since Jan 19Pushed 2y agoCompare

[ Source](https://github.com/murzid/codeigniter-datatables)[ Packagist](https://packagist.org/packages/murzid/codeigniter-datatables)[ RSS](/packages/murzid-codeigniter-datatables/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

CodeIgniter DataTables
======================

[](#codeigniter-datatables)

DataTables server-side for CodeIgniter, supported for both CodeIgniter 3 and CodeIgniter 4.

**Note:** This library only handle the server-side part, you still needs to configure the client side like jQuery, DataTables library and including the styles. Don't worry, we already give the examples below.

Requirements
------------

[](#requirements)

If you are using CodeIgniter, let's go! You don't needs any extra requirements.

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

[](#installation)

You just need to use composer and everything is done.

```
composer require murzid/codeigniter-datatables
```

Usage
-----

[](#usage)

Here is the basic example to use this library, you are freely make any changes for the client side, like defining searchable column, orderable column, etc...

### CodeIgniter 3 Example

[](#codeigniter-3-example)

```
// CodeIgniter 3 Example

// Here we will select all fields from posts table
// and make a join with categories table
// Please note: we don't need to call ->get() here
$queryBuilder = $this->db->select('p.*, c.name category')
                    ->from('posts p')
                    ->join('categories c', 'c.id=p.category_id');

/**
 * The first parameter is the query builder instance
 * and the second is the codeigniter version (3 or 4)
 */
$datatables = new Murzid\CodeIgniterDataTables\DataTables($queryBuilder, '3');
$datatables->generate(); // done
```

### CodeIgniter 4 Example

[](#codeigniter-4-example)

```
// CodeIgniter 4 Example

$db = db_connect();
$queryBuilder = $db->from('posts p')
                   ->select('p.*, c.name category')
                   ->join('categories c', 'c.id=p.category_id');

$datatables = new Murzid\CodeIgniterDataTables\DataTables($queryBuilder, '4');
$datatables->generate(); // done
```

**The above examples will give you for [ajax data source (arrays)](https://datatables.net/examples/ajax/simple.html), so you need to make sure the table header you makes for the client side is match with the ajax response. We will talk about the objects data source below.**

### Client Side Examples

[](#client-side-examples)

You must include the jQuery and DataTables library.

```

    ID
    Title
    Category
    Description

$('#table-post').DataTable({
  processing: true,
  serverSide: true,
  ajax: {
    url: 'http://localhost/project/index.php/post/ajax_datatables', // Change with your own
    method: 'GET', // You are freely to use POST or GET
  }
})

```

Objects Data Source
-------------------

[](#objects-data-source)

As was mentioned above, the default data source we get is an arrays. It is easy also to get the objects data source.

To get objects response, you just need to call `asObject()` method.

```
$datatables->asObject()
           ->generate();
```

And then you can configure the client side with columns option to fit your data.

```
$('#table-post').DataTable({
  processing: true,
  serverSide: true,
  ajax: {
    url: 'http://localhost/project/index.php/post/ajax_datatables',
    method: 'GET',
  },
  columns: [
    { data: 'id' },
    { data: 'title' },
    { data: 'category' },
    { data: 'description' }
  ]
})

```

Some Others Settings
--------------------

[](#some-others-settings)

Some basic functionalities already available, here is the full settings you can doing to this library.

### Use class for spesify the CodeIgniter version

[](#use-class-for-spesify-the-codeigniter-version)

```
// General, use the second param to define the version
// The default is 4
$datatables = new Murzid\CodeIgniterDataTables\DataTables($queryBuilder, '3');

// CodeIgniter 3
$datatables = new Murzid\CodeIgniterDataTables\DataTablesCodeIgniter3($queryBuilder);

// CodeIgniter 4
$datatables = new Murzid\CodeIgniterDataTables\DataTablesCodeIgniter4($queryBuilder);
```

### Available Options

[](#available-options)

```
$datatables = new Murzid\CodeIgniterDataTables\DataTables($queryBuilder);

// Return the output as objects instead of arrays
$datatables->asObject();

// Only return title & category (accept string or array)
$datatables->only(['title', 'category']);

// Return all except the id
// You may use one of only or except
$datatables->except(['id']);

// Format the output
$datatables->format('title', function($value, $row) {
  return ''.$value.'';
});

// Add extra column
$datatables->addColumn('action', function($row) {
  return 'Delete';
});

// Add column alias
// It is very useful when we use SELECT JOIN to prevent column ambiguous
$datatables->addColumnAlias('p.id', 'id');

// Add column aliases
// Same as the addColumnAlias, but for multiple alias at once
$datatables->addColumnAliases([
  'p.id' => 'id',
  'c.name' => 'category'
]);

// Add squence number
// The default key is `sequenceNumber`
// You can change it with give the param
$datatables->addSequenceNumber();
$datatables->addSequenceNumber('rowNumber'); // It will be rowNumber

// Don't forget ot call generate to get the results (send to output buffer)
$datatables->generate();

// Output Content
// TRUE = Send to output buffer (default)
// FALSE = Return generated data as array without send to output buffer
$output_buffer = FALSE;

// Additional Custom Data (array)
$extra_data = [

  // Set Custom Data
  'customField' => 'customValue',

  // Enable Query Debugging (Last Query)
  'debug' => TRUE,
];

// Call generate to get the custom results
$result = $datatables->generate($output_buffer, $extra_data);
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 82.4% 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 ~1 days

Total

3

Last Release

847d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ae8d0a0931b30dacd0642b7f7f009d122a08266e4a537221ed14a36a1368bf2?d=identicon)[murzid](/maintainers/murzid)

---

Top Contributors

[![ngekoding](https://avatars.githubusercontent.com/u/11625690?v=4)](https://github.com/ngekoding "ngekoding (14 commits)")[![murzid](https://avatars.githubusercontent.com/u/4926456?v=4)](https://github.com/murzid "murzid (3 commits)")

### Embed Badge

![Health badge](/badges/murzid-codeigniter-datatables/health.svg)

```
[![Health](https://phpackages.com/badges/murzid-codeigniter-datatables/health.svg)](https://phpackages.com/packages/murzid-codeigniter-datatables)
```

###  Alternatives

[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[laravel/reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

1.6k9.4M48](/packages/laravel-reverb)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)

PHPackages © 2026

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